@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | { |
15 | 15 | protected $httpProblem; |
16 | 16 | |
17 | - public function __construct( HttpProblem $httpProblem = null, $previous=null ) |
|
17 | + public function __construct(HttpProblem $httpProblem = null, $previous = null) |
|
18 | 18 | { |
19 | 19 | if (is_null($httpProblem)) $httpProblem = new HttpProblem; |
20 | 20 | parent::__construct($httpProblem->title, $httpProblem->httpStatus, $previous); |
@@ -22,9 +22,9 @@ discard block |
||
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | - public static function factory(HttpProblem $httpProblem = null, $previous=null ) |
|
25 | + public static function factory(HttpProblem $httpProblem = null, $previous = null) |
|
26 | 26 | { |
27 | - return new static($httpProblem, $previous ); |
|
27 | + return new static($httpProblem, $previous); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 |
@@ -16,7 +16,9 @@ |
||
16 | 16 | |
17 | 17 | public function __construct( HttpProblem $httpProblem = null, $previous=null ) |
18 | 18 | { |
19 | - if (is_null($httpProblem)) $httpProblem = new HttpProblem; |
|
19 | + if (is_null($httpProblem)) { |
|
20 | + $httpProblem = new HttpProblem; |
|
21 | + } |
|
20 | 22 | parent::__construct($httpProblem->title, $httpProblem->httpStatus, $previous); |
21 | 23 | $this->httpProblem = $httpProblem; |
22 | 24 | } |
@@ -8,21 +8,21 @@ |
||
8 | 8 | /** |
9 | 9 | * Create and Endpoint and setup auto virtualhost |
10 | 10 | */ |
11 | - public static function make($endPointClass=null,$virtualhost=null) |
|
11 | + public static function make($endPointClass = null, $virtualhost = null) |
|
12 | 12 | { |
13 | 13 | $baseEndPointClassName = '\\BOTK\\Core\\EndPoint'; |
14 | 14 | if (!$endPointClass) $endPointClass = $baseEndPointClassName; |
15 | 15 | |
16 | - if($endPointClass!=$baseEndPointClassName |
|
17 | - && !is_subclass_of($endPointClass, $baseEndPointClassName)){ |
|
18 | - throw new HttpErrorException( HttpProblem::factory( |
|
16 | + if ($endPointClass != $baseEndPointClassName |
|
17 | + && !is_subclass_of($endPointClass, $baseEndPointClassName)) { |
|
18 | + throw new HttpErrorException(HttpProblem::factory( |
|
19 | 19 | 500, 'Unable to create endpoint', "$endPointClass is not and EndPoint class")); |
20 | 20 | } |
21 | 21 | |
22 | 22 | return new $endPointClass($virtualhost); |
23 | 23 | } |
24 | 24 | |
25 | - public static function factory($virtualhost=null) |
|
25 | + public static function factory($virtualhost = null) |
|
26 | 26 | { |
27 | 27 | return new static($virtualhost); |
28 | 28 | } |
@@ -11,7 +11,9 @@ |
||
11 | 11 | public static function make($endPointClass=null,$virtualhost=null) |
12 | 12 | { |
13 | 13 | $baseEndPointClassName = '\\BOTK\\Core\\EndPoint'; |
14 | - if (!$endPointClass) $endPointClass = $baseEndPointClassName; |
|
14 | + if (!$endPointClass) { |
|
15 | + $endPointClass = $baseEndPointClassName; |
|
16 | + } |
|
15 | 17 | |
16 | 18 | if($endPointClass!=$baseEndPointClassName |
17 | 19 | && !is_subclass_of($endPointClass, $baseEndPointClassName)){ |
@@ -8,94 +8,94 @@ |
||
8 | 8 | |
9 | 9 | class WebLink |
10 | 10 | { |
11 | - // Consider thes as readonly vars |
|
12 | - public $href='', |
|
11 | + // Consider thes as readonly vars |
|
12 | + public $href='', |
|
13 | 13 | $rel=null, |
14 | 14 | $type=null, |
15 | 15 | $title=null, |
16 | 16 | $hreflang=null, |
17 | 17 | $media; |
18 | 18 | |
19 | - public static function factory($href=null) |
|
20 | - { |
|
21 | - if (is_null($href)) $href = ''; |
|
22 | - $link = new static(); |
|
19 | + public static function factory($href=null) |
|
20 | + { |
|
21 | + if (is_null($href)) $href = ''; |
|
22 | + $link = new static(); |
|
23 | 23 | |
24 | - return $link->href($href); |
|
25 | - } |
|
24 | + return $link->href($href); |
|
25 | + } |
|
26 | 26 | |
27 | - public function href($href) |
|
28 | - { |
|
29 | - $this->href = $href; |
|
30 | - return $this; |
|
31 | - } |
|
27 | + public function href($href) |
|
28 | + { |
|
29 | + $this->href = $href; |
|
30 | + return $this; |
|
31 | + } |
|
32 | 32 | |
33 | - public function rel($rel) |
|
34 | - { |
|
35 | - $this->rel = $rel; |
|
36 | - return $this; |
|
37 | - } |
|
33 | + public function rel($rel) |
|
34 | + { |
|
35 | + $this->rel = $rel; |
|
36 | + return $this; |
|
37 | + } |
|
38 | 38 | |
39 | - public function type($type) |
|
40 | - { |
|
41 | - $this->type = $type; |
|
42 | - return $this; |
|
43 | - } |
|
39 | + public function type($type) |
|
40 | + { |
|
41 | + $this->type = $type; |
|
42 | + return $this; |
|
43 | + } |
|
44 | 44 | |
45 | - public function title($title) |
|
46 | - { |
|
47 | - $this->title = $title; |
|
48 | - return $this; |
|
49 | - } |
|
45 | + public function title($title) |
|
46 | + { |
|
47 | + $this->title = $title; |
|
48 | + return $this; |
|
49 | + } |
|
50 | 50 | |
51 | - public function media($media) |
|
52 | - { |
|
53 | - $this->media = $media; |
|
54 | - return $this; |
|
55 | - } |
|
51 | + public function media($media) |
|
52 | + { |
|
53 | + $this->media = $media; |
|
54 | + return $this; |
|
55 | + } |
|
56 | 56 | |
57 | - public function hreflang($hreflang) |
|
58 | - { |
|
59 | - $this->hreflang = $hreflang; |
|
60 | - return $this; |
|
61 | - } |
|
57 | + public function hreflang($hreflang) |
|
58 | + { |
|
59 | + $this->hreflang = $hreflang; |
|
60 | + return $this; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Link serialization for http header |
|
65 | - */ |
|
66 | - private function getTargetAttributes() |
|
67 | - { |
|
68 | - $fields = get_object_vars($this); |
|
69 | - unset($fields['href']); |
|
70 | - return($fields); |
|
71 | - } |
|
63 | + /** |
|
64 | + * Link serialization for http header |
|
65 | + */ |
|
66 | + private function getTargetAttributes() |
|
67 | + { |
|
68 | + $fields = get_object_vars($this); |
|
69 | + unset($fields['href']); |
|
70 | + return($fields); |
|
71 | + } |
|
72 | 72 | |
73 | - public function httpSerializer() |
|
74 | - { |
|
75 | - $s = "Link: <$this->href>"; |
|
76 | - foreach ( $this->getTargetAttributes() as $name => $val){ |
|
73 | + public function httpSerializer() |
|
74 | + { |
|
75 | + $s = "Link: <$this->href>"; |
|
76 | + foreach ( $this->getTargetAttributes() as $name => $val){ |
|
77 | 77 | if ($val) $s .= "; $name=\"$val\""; |
78 | - } |
|
79 | - return $s; |
|
80 | - } |
|
78 | + } |
|
79 | + return $s; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Poor man parsing... just reliable for parsing httpSerialized links. Only double quoting allowed. |
|
84 | - * attributes supported... |
|
85 | - */ |
|
86 | - public function httpParse($s) |
|
87 | - { |
|
88 | - if (preg_match('/Link:\s*<(.*)>/', $s,$matches)){ |
|
89 | - $link = static::factory($matches[1]); |
|
90 | - foreach ( $this->getTargetAttributes() as $name => $val){ |
|
91 | - if(preg_match('/'.$name.'\s*=\s*"([^"]*)"/', $s,$matches)){ |
|
82 | + /** |
|
83 | + * Poor man parsing... just reliable for parsing httpSerialized links. Only double quoting allowed. |
|
84 | + * attributes supported... |
|
85 | + */ |
|
86 | + public function httpParse($s) |
|
87 | + { |
|
88 | + if (preg_match('/Link:\s*<(.*)>/', $s,$matches)){ |
|
89 | + $link = static::factory($matches[1]); |
|
90 | + foreach ( $this->getTargetAttributes() as $name => $val){ |
|
91 | + if(preg_match('/'.$name.'\s*=\s*"([^"]*)"/', $s,$matches)){ |
|
92 | 92 | $link->$name(trim($matches[1])); |
93 | - } |
|
94 | - } |
|
95 | - } else { |
|
96 | - $link = false; |
|
97 | - } |
|
93 | + } |
|
94 | + } |
|
95 | + } else { |
|
96 | + $link = false; |
|
97 | + } |
|
98 | 98 | |
99 | - return $link; |
|
100 | - } |
|
99 | + return $link; |
|
100 | + } |
|
101 | 101 | } |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | class WebLink |
10 | 10 | { |
11 | 11 | // Consider thes as readonly vars |
12 | - public $href='', |
|
13 | - $rel=null, |
|
14 | - $type=null, |
|
15 | - $title=null, |
|
16 | - $hreflang=null, |
|
12 | + public $href = '', |
|
13 | + $rel = null, |
|
14 | + $type = null, |
|
15 | + $title = null, |
|
16 | + $hreflang = null, |
|
17 | 17 | $media; |
18 | 18 | |
19 | - public static function factory($href=null) |
|
19 | + public static function factory($href = null) |
|
20 | 20 | { |
21 | 21 | if (is_null($href)) $href = ''; |
22 | 22 | $link = new static(); |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function httpSerializer() |
74 | 74 | { |
75 | 75 | $s = "Link: <$this->href>"; |
76 | - foreach ( $this->getTargetAttributes() as $name => $val){ |
|
76 | + foreach ($this->getTargetAttributes() as $name => $val) { |
|
77 | 77 | if ($val) $s .= "; $name=\"$val\""; |
78 | 78 | } |
79 | 79 | return $s; |
@@ -85,10 +85,10 @@ discard block |
||
85 | 85 | */ |
86 | 86 | public function httpParse($s) |
87 | 87 | { |
88 | - if (preg_match('/Link:\s*<(.*)>/', $s,$matches)){ |
|
88 | + if (preg_match('/Link:\s*<(.*)>/', $s, $matches)) { |
|
89 | 89 | $link = static::factory($matches[1]); |
90 | - foreach ( $this->getTargetAttributes() as $name => $val){ |
|
91 | - if(preg_match('/'.$name.'\s*=\s*"([^"]*)"/', $s,$matches)){ |
|
90 | + foreach ($this->getTargetAttributes() as $name => $val) { |
|
91 | + if (preg_match('/'.$name.'\s*=\s*"([^"]*)"/', $s, $matches)) { |
|
92 | 92 | $link->$name(trim($matches[1])); |
93 | 93 | } |
94 | 94 | } |
@@ -18,7 +18,9 @@ discard block |
||
18 | 18 | |
19 | 19 | public static function factory($href=null) |
20 | 20 | { |
21 | - if (is_null($href)) $href = ''; |
|
21 | + if (is_null($href)) { |
|
22 | + $href = ''; |
|
23 | + } |
|
22 | 24 | $link = new static(); |
23 | 25 | |
24 | 26 | return $link->href($href); |
@@ -74,7 +76,9 @@ discard block |
||
74 | 76 | { |
75 | 77 | $s = "Link: <$this->href>"; |
76 | 78 | foreach ( $this->getTargetAttributes() as $name => $val){ |
77 | - if ($val) $s .= "; $name=\"$val\""; |
|
79 | + if ($val) { |
|
80 | + $s .= "; $name=\"$val\""; |
|
81 | + } |
|
78 | 82 | } |
79 | 83 | return $s; |
80 | 84 | } |