@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | */ |
27 | 27 | class OperationResult_Collection extends OperationResult |
28 | 28 | { |
29 | - /** |
|
30 | - * @var OperationResult[] |
|
31 | - */ |
|
29 | + /** |
|
30 | + * @var OperationResult[] |
|
31 | + */ |
|
32 | 32 | protected $results = array(); |
33 | 33 | |
34 | 34 | public function makeError(string $message, int $code=0) : OperationResult |
@@ -106,9 +106,9 @@ discard block |
||
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - /** |
|
110 | - * @return OperationResult[] |
|
111 | - */ |
|
109 | + /** |
|
110 | + * @return OperationResult[] |
|
111 | + */ |
|
112 | 112 | public function getResults() : array |
113 | 113 | { |
114 | 114 | return $this->results; |
@@ -31,27 +31,27 @@ discard block |
||
31 | 31 | */ |
32 | 32 | protected $results = array(); |
33 | 33 | |
34 | - public function makeError(string $message, int $code=0) : OperationResult |
|
34 | + public function makeError(string $message, int $code = 0) : OperationResult |
|
35 | 35 | { |
36 | 36 | return $this->add('makeError', $message, $code); |
37 | 37 | } |
38 | 38 | |
39 | - public function makeSuccess(string $message, int $code=0) : OperationResult |
|
39 | + public function makeSuccess(string $message, int $code = 0) : OperationResult |
|
40 | 40 | { |
41 | 41 | return $this->add('makeSuccess', $message, $code); |
42 | 42 | } |
43 | 43 | |
44 | - public function makeWarning(string $message, int $code=0) : OperationResult |
|
44 | + public function makeWarning(string $message, int $code = 0) : OperationResult |
|
45 | 45 | { |
46 | 46 | return $this->add('makeWarning', $message, $code); |
47 | 47 | } |
48 | 48 | |
49 | - public function makeNotice(string $message, int $code=0) : OperationResult |
|
49 | + public function makeNotice(string $message, int $code = 0) : OperationResult |
|
50 | 50 | { |
51 | 51 | return $this->add('makeNotice', $message, $code); |
52 | 52 | } |
53 | 53 | |
54 | - protected function add(string $method, string $message, int $code=0) : OperationResult |
|
54 | + protected function add(string $method, string $message, int $code = 0) : OperationResult |
|
55 | 55 | { |
56 | 56 | $result = new OperationResult($this->subject); |
57 | 57 | $result->$method($message, $code); |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | |
64 | 64 | public function addResult(OperationResult $result) : OperationResult_Collection |
65 | 65 | { |
66 | - if($result instanceof OperationResult_Collection) |
|
66 | + if ($result instanceof OperationResult_Collection) |
|
67 | 67 | { |
68 | 68 | return $this->importCollection($result); |
69 | 69 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | { |
76 | 76 | $results = $collection->getResults(); |
77 | 77 | |
78 | - foreach($results as $result) |
|
78 | + foreach ($results as $result) |
|
79 | 79 | { |
80 | 80 | $this->addResult($result); |
81 | 81 | } |
@@ -111,9 +111,9 @@ discard block |
||
111 | 111 | |
112 | 112 | public function isValid() : bool |
113 | 113 | { |
114 | - foreach($this->results as $result) |
|
114 | + foreach ($this->results as $result) |
|
115 | 115 | { |
116 | - if(!$result->isValid()) |
|
116 | + if (!$result->isValid()) |
|
117 | 117 | { |
118 | 118 | return false; |
119 | 119 | } |
@@ -124,9 +124,9 @@ discard block |
||
124 | 124 | |
125 | 125 | public function hasCode() : bool |
126 | 126 | { |
127 | - foreach($this->results as $result) |
|
127 | + foreach ($this->results as $result) |
|
128 | 128 | { |
129 | - if($result->hasCode()) |
|
129 | + if ($result->hasCode()) |
|
130 | 130 | { |
131 | 131 | return true; |
132 | 132 | } |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | |
138 | 138 | public function getCode() : int |
139 | 139 | { |
140 | - foreach($this->results as $result) |
|
140 | + foreach ($this->results as $result) |
|
141 | 141 | { |
142 | - if($result->hasCode()) |
|
142 | + if ($result->hasCode()) |
|
143 | 143 | { |
144 | 144 | return $result->getCode(); |
145 | 145 | } |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | return 0; |
149 | 149 | } |
150 | 150 | |
151 | - public function getMessage(string $type='') : string |
|
151 | + public function getMessage(string $type = '') : string |
|
152 | 152 | { |
153 | - foreach($this->results as $result) |
|
153 | + foreach ($this->results as $result) |
|
154 | 154 | { |
155 | 155 | $msg = $result->getMessage($type); |
156 | 156 | |
157 | - if(!empty($msg)) |
|
157 | + if (!empty($msg)) |
|
158 | 158 | { |
159 | 159 | return $msg; |
160 | 160 | } |
@@ -165,9 +165,9 @@ discard block |
||
165 | 165 | |
166 | 166 | public function containsCode(int $code) : bool |
167 | 167 | { |
168 | - foreach($this->results as $result) |
|
168 | + foreach ($this->results as $result) |
|
169 | 169 | { |
170 | - if($result->getCode() === $code) |
|
170 | + if ($result->getCode() === $code) |
|
171 | 171 | { |
172 | 172 | return true; |
173 | 173 | } |
@@ -200,9 +200,9 @@ discard block |
||
200 | 200 | { |
201 | 201 | $amount = 0; |
202 | 202 | |
203 | - foreach($this->results as $result) |
|
203 | + foreach ($this->results as $result) |
|
204 | 204 | { |
205 | - if($result->isType($type)) |
|
205 | + if ($result->isType($type)) |
|
206 | 206 | { |
207 | 207 | $amount++; |
208 | 208 | } |
@@ -240,9 +240,9 @@ discard block |
||
240 | 240 | { |
241 | 241 | $results = array(); |
242 | 242 | |
243 | - foreach($this->results as $result) |
|
243 | + foreach ($this->results as $result) |
|
244 | 244 | { |
245 | - if($result->isType($type)) |
|
245 | + if ($result->isType($type)) |
|
246 | 246 | { |
247 | 247 | $results[] = $result; |
248 | 248 | } |
@@ -253,9 +253,9 @@ discard block |
||
253 | 253 | |
254 | 254 | public function isType(string $type) : bool |
255 | 255 | { |
256 | - foreach($this->results as $result) |
|
256 | + foreach ($this->results as $result) |
|
257 | 257 | { |
258 | - if($result->isType($type)) |
|
258 | + if ($result->isType($type)) |
|
259 | 259 | { |
260 | 260 | return true; |
261 | 261 | } |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | $lines[] = 'Collection #'.$this->getID(); |
272 | 272 | $lines[] = 'Subject: '.get_class($this->subject); |
273 | 273 | |
274 | - foreach($this->results as $result) |
|
274 | + foreach ($this->results as $result) |
|
275 | 275 | { |
276 | 276 | $lines[] = ' - '.$result->getType().' #'.$result->getCode().' "'.$result->getMessage($result->getType()).'"'; |
277 | 277 | } |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | */ |
26 | 26 | trait Traits_Classable |
27 | 27 | { |
28 | - /** |
|
29 | - * @var string[] |
|
30 | - */ |
|
28 | + /** |
|
29 | + * @var string[] |
|
30 | + */ |
|
31 | 31 | protected $classes = array(); |
32 | 32 | |
33 | 33 | public function addClass(string $name) |
@@ -65,30 +65,30 @@ discard block |
||
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - /** |
|
69 | - * Retrieves a list of all classes, if any. |
|
70 | - * |
|
71 | - * @return string[] |
|
72 | - */ |
|
68 | + /** |
|
69 | + * Retrieves a list of all classes, if any. |
|
70 | + * |
|
71 | + * @return string[] |
|
72 | + */ |
|
73 | 73 | public function getClasses() : array |
74 | 74 | { |
75 | 75 | return $this->classes; |
76 | 76 | } |
77 | 77 | |
78 | - /** |
|
79 | - * Renders the class names list as space-separated string for use in an HTML tag. |
|
80 | - * |
|
81 | - * @return string |
|
82 | - */ |
|
78 | + /** |
|
79 | + * Renders the class names list as space-separated string for use in an HTML tag. |
|
80 | + * |
|
81 | + * @return string |
|
82 | + */ |
|
83 | 83 | public function classesToString() : string |
84 | 84 | { |
85 | 85 | return implode(' ', $this->classes); |
86 | 86 | } |
87 | 87 | |
88 | - /** |
|
89 | - * Renders the "class" attribute string for inserting into an HTML tag. |
|
90 | - * @return string |
|
91 | - */ |
|
88 | + /** |
|
89 | + * Renders the "class" attribute string for inserting into an HTML tag. |
|
90 | + * @return string |
|
91 | + */ |
|
92 | 92 | public function classesToAttribute() : string |
93 | 93 | { |
94 | 94 | if(!empty($this->classes)) |
@@ -117,42 +117,42 @@ discard block |
||
117 | 117 | */ |
118 | 118 | interface Interface_Classable |
119 | 119 | { |
120 | - /** |
|
121 | - * @param string $name |
|
122 | - * @return $this |
|
123 | - */ |
|
120 | + /** |
|
121 | + * @param string $name |
|
122 | + * @return $this |
|
123 | + */ |
|
124 | 124 | public function addClass(string $name); |
125 | 125 | |
126 | - /** |
|
127 | - * @param array $names |
|
128 | - * @return $this |
|
129 | - */ |
|
126 | + /** |
|
127 | + * @param array $names |
|
128 | + * @return $this |
|
129 | + */ |
|
130 | 130 | public function addClasses(array $names); |
131 | 131 | |
132 | - /** |
|
133 | - * @param string $name |
|
134 | - * @return bool |
|
135 | - */ |
|
132 | + /** |
|
133 | + * @param string $name |
|
134 | + * @return bool |
|
135 | + */ |
|
136 | 136 | public function hasClass(string $name) : bool; |
137 | 137 | |
138 | - /** |
|
139 | - * @param string $name |
|
140 | - * @return $this |
|
141 | - */ |
|
138 | + /** |
|
139 | + * @param string $name |
|
140 | + * @return $this |
|
141 | + */ |
|
142 | 142 | public function removeClass(string $name); |
143 | 143 | |
144 | - /** |
|
145 | - * @return array |
|
146 | - */ |
|
144 | + /** |
|
145 | + * @return array |
|
146 | + */ |
|
147 | 147 | public function getClasses() : array; |
148 | 148 | |
149 | - /** |
|
150 | - * @return string |
|
151 | - */ |
|
149 | + /** |
|
150 | + * @return string |
|
151 | + */ |
|
152 | 152 | public function classesToString() : string; |
153 | 153 | |
154 | - /** |
|
155 | - * @return string |
|
156 | - */ |
|
154 | + /** |
|
155 | + * @return string |
|
156 | + */ |
|
157 | 157 | public function classesToAttribute() : string; |
158 | 158 | } |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public function addClass(string $name) |
34 | 34 | { |
35 | - if(!in_array($name, $this->classes)) { |
|
35 | + if (!in_array($name, $this->classes)) { |
|
36 | 36 | $this->classes[] = $name; |
37 | 37 | } |
38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | |
42 | 42 | public function addClasses(array $names) |
43 | 43 | { |
44 | - foreach($names as $name) { |
|
44 | + foreach ($names as $name) { |
|
45 | 45 | $this->addClass($name); |
46 | 46 | } |
47 | 47 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | { |
58 | 58 | $idx = array_search($name, $this->classes); |
59 | 59 | |
60 | - if($idx !== false) { |
|
60 | + if ($idx !== false) { |
|
61 | 61 | unset($this->classes[$idx]); |
62 | 62 | sort($this->classes); |
63 | 63 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | */ |
92 | 92 | public function classesToAttribute() : string |
93 | 93 | { |
94 | - if(!empty($this->classes)) |
|
94 | + if (!empty($this->classes)) |
|
95 | 95 | { |
96 | 96 | return sprintf( |
97 | 97 | ' class="%s" ', |
@@ -24,19 +24,19 @@ discard block |
||
24 | 24 | { |
25 | 25 | use Traits_Optionable; |
26 | 26 | |
27 | - /** |
|
28 | - * @see https://gist.github.com/gruber/249502 |
|
29 | - */ |
|
27 | + /** |
|
28 | + * @see https://gist.github.com/gruber/249502 |
|
29 | + */ |
|
30 | 30 | const REGEX_URL = '#(?i)\b((?:[a-z][\w-]+:(?:/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))#i'; |
31 | 31 | |
32 | - /** |
|
33 | - * @var string |
|
34 | - */ |
|
32 | + /** |
|
33 | + * @var string |
|
34 | + */ |
|
35 | 35 | protected $subject; |
36 | 36 | |
37 | - /** |
|
38 | - * @var string[] |
|
39 | - */ |
|
37 | + /** |
|
38 | + * @var string[] |
|
39 | + */ |
|
40 | 40 | protected $schemes = array( |
41 | 41 | 'http', |
42 | 42 | 'https', |
@@ -62,49 +62,49 @@ discard block |
||
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | - /** |
|
66 | - * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
67 | - * |
|
68 | - * @param bool $enabled |
|
69 | - * @return ConvertHelper_URLFinder |
|
70 | - */ |
|
65 | + /** |
|
66 | + * Whether to enable sorting the URLs alphabetically (disabled by default). |
|
67 | + * |
|
68 | + * @param bool $enabled |
|
69 | + * @return ConvertHelper_URLFinder |
|
70 | + */ |
|
71 | 71 | public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
72 | 72 | { |
73 | 73 | $this->setOption('sorting', $enabled); |
74 | 74 | return $this; |
75 | 75 | } |
76 | 76 | |
77 | - /** |
|
78 | - * Whether to include email addresses in the search. |
|
79 | - * This is only relevant when using the getURLs() |
|
80 | - * method. |
|
81 | - * |
|
82 | - * @param bool $include |
|
83 | - * @return ConvertHelper_URLFinder |
|
84 | - */ |
|
77 | + /** |
|
78 | + * Whether to include email addresses in the search. |
|
79 | + * This is only relevant when using the getURLs() |
|
80 | + * method. |
|
81 | + * |
|
82 | + * @param bool $include |
|
83 | + * @return ConvertHelper_URLFinder |
|
84 | + */ |
|
85 | 85 | public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
86 | 86 | { |
87 | 87 | $this->setOption('include-emails', $include); |
88 | 88 | return $this; |
89 | 89 | } |
90 | 90 | |
91 | - /** |
|
92 | - * Whether to omit the mailto: that is automatically added to all email addresses. |
|
93 | - * |
|
94 | - * @param bool $omit |
|
95 | - * @return ConvertHelper_URLFinder |
|
96 | - */ |
|
91 | + /** |
|
92 | + * Whether to omit the mailto: that is automatically added to all email addresses. |
|
93 | + * |
|
94 | + * @param bool $omit |
|
95 | + * @return ConvertHelper_URLFinder |
|
96 | + */ |
|
97 | 97 | public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
98 | 98 | { |
99 | 99 | $this->setOption('omit-mailto', $omit); |
100 | 100 | return $this; |
101 | 101 | } |
102 | 102 | |
103 | - /** |
|
104 | - * Prepares the subject string by adding a newline before all URL schemes, |
|
105 | - * to make it possible to parse even lists of links separated by commas or |
|
106 | - * the like (http://domain.com,http://domain2.com). |
|
107 | - */ |
|
103 | + /** |
|
104 | + * Prepares the subject string by adding a newline before all URL schemes, |
|
105 | + * to make it possible to parse even lists of links separated by commas or |
|
106 | + * the like (http://domain.com,http://domain2.com). |
|
107 | + */ |
|
108 | 108 | private function prepareSubject() : void |
109 | 109 | { |
110 | 110 | $replaces = array(); |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | $this->subject = str_replace(array_keys($replaces), array_values($replaces), $this->subject); |
118 | 118 | } |
119 | 119 | |
120 | - /** |
|
121 | - * Fetches all URLs that can be found in the subject string. |
|
122 | - * |
|
123 | - * @return string[] |
|
124 | - */ |
|
120 | + /** |
|
121 | + * Fetches all URLs that can be found in the subject string. |
|
122 | + * |
|
123 | + * @return string[] |
|
124 | + */ |
|
125 | 125 | public function getURLs() : array |
126 | 126 | { |
127 | 127 | $this->prepareSubject(); |
@@ -154,13 +154,13 @@ discard block |
||
154 | 154 | return $result; |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * Retrieves all email addresses from the subject string. |
|
159 | - * |
|
160 | - * @return string[] |
|
161 | - * |
|
162 | - * @see omitMailto() |
|
163 | - */ |
|
157 | + /** |
|
158 | + * Retrieves all email addresses from the subject string. |
|
159 | + * |
|
160 | + * @return string[] |
|
161 | + * |
|
162 | + * @see omitMailto() |
|
163 | + */ |
|
164 | 164 | public function getEmails() : array |
165 | 165 | { |
166 | 166 | $matches = array(); |
@@ -194,11 +194,11 @@ discard block |
||
194 | 194 | return 'mailto:'; |
195 | 195 | } |
196 | 196 | |
197 | - /** |
|
198 | - * Retrieves all URLs as URLInfo instances. |
|
199 | - * |
|
200 | - * @return URLInfo[] |
|
201 | - */ |
|
197 | + /** |
|
198 | + * Retrieves all URLs as URLInfo instances. |
|
199 | + * |
|
200 | + * @return URLInfo[] |
|
201 | + */ |
|
202 | 202 | public function getInfos() |
203 | 203 | { |
204 | 204 | $urls = $this->getURLs(); |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | * @param bool $enabled |
69 | 69 | * @return ConvertHelper_URLFinder |
70 | 70 | */ |
71 | - public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
|
71 | + public function enableSorting(bool $enabled = true) : ConvertHelper_URLFinder |
|
72 | 72 | { |
73 | 73 | $this->setOption('sorting', $enabled); |
74 | 74 | return $this; |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param bool $include |
83 | 83 | * @return ConvertHelper_URLFinder |
84 | 84 | */ |
85 | - public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
|
85 | + public function includeEmails(bool $include = true) : ConvertHelper_URLFinder |
|
86 | 86 | { |
87 | 87 | $this->setOption('include-emails', $include); |
88 | 88 | return $this; |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | * @param bool $omit |
95 | 95 | * @return ConvertHelper_URLFinder |
96 | 96 | */ |
97 | - public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
|
97 | + public function omitMailto(bool $omit = true) : ConvertHelper_URLFinder |
|
98 | 98 | { |
99 | 99 | $this->setOption('omit-mailto', $omit); |
100 | 100 | return $this; |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | { |
110 | 110 | $replaces = array(); |
111 | 111 | |
112 | - foreach($this->schemes as $scheme) |
|
112 | + foreach ($this->schemes as $scheme) |
|
113 | 113 | { |
114 | 114 | $replaces[$scheme.':'] = PHP_EOL.$scheme.':'; |
115 | 115 | } |
@@ -131,20 +131,20 @@ discard block |
||
131 | 131 | |
132 | 132 | $result = array(); |
133 | 133 | |
134 | - foreach($matches[0] as $match) |
|
134 | + foreach ($matches[0] as $match) |
|
135 | 135 | { |
136 | - if(strstr($match, '://') && !in_array($match, $result)) |
|
136 | + if (strstr($match, '://') && !in_array($match, $result)) |
|
137 | 137 | { |
138 | 138 | $result[] = $match; |
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | - if($this->getBoolOption('include-emails')) |
|
142 | + if ($this->getBoolOption('include-emails')) |
|
143 | 143 | { |
144 | 144 | $result = array_merge($result, $this->getEmails()); |
145 | 145 | } |
146 | 146 | |
147 | - if($this->getBoolOption('sorting')) |
|
147 | + if ($this->getBoolOption('sorting')) |
|
148 | 148 | { |
149 | 149 | usort($result, function(string $a, string $b) { |
150 | 150 | return strnatcasecmp($a, $b); |
@@ -169,12 +169,12 @@ discard block |
||
169 | 169 | $result = array(); |
170 | 170 | $prefix = $this->getEmailPrefix(); |
171 | 171 | |
172 | - foreach($matches[0] as $email) |
|
172 | + foreach ($matches[0] as $email) |
|
173 | 173 | { |
174 | 174 | $result[] = $prefix.$email; |
175 | 175 | } |
176 | 176 | |
177 | - if($this->getBoolOption('sorting')) |
|
177 | + if ($this->getBoolOption('sorting')) |
|
178 | 178 | { |
179 | 179 | usort($result, function(string $a, string $b) { |
180 | 180 | return strnatcasecmp($a, $b); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | |
187 | 187 | private function getEmailPrefix() : string |
188 | 188 | { |
189 | - if($this->getBoolOption('omit-mailto')) |
|
189 | + if ($this->getBoolOption('omit-mailto')) |
|
190 | 190 | { |
191 | 191 | return ''; |
192 | 192 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | |
206 | 206 | $result = array(); |
207 | 207 | |
208 | - foreach($urls as $url) |
|
208 | + foreach ($urls as $url) |
|
209 | 209 | { |
210 | 210 | $result[] = parseURL($url); |
211 | 211 | } |