@@ -126,13 +126,13 @@ discard block |
||
126 | 126 | $this->detectNamespace($code); |
127 | 127 | $result = $this->detectMatches($code); |
128 | 128 | |
129 | - if($result === null) { |
|
129 | + if ($result === null) { |
|
130 | 130 | return; |
131 | 131 | } |
132 | 132 | |
133 | 133 | $indexes = array_keys($result[0]); |
134 | 134 | |
135 | - foreach($indexes as $idx) |
|
135 | + foreach ($indexes as $idx) |
|
136 | 136 | { |
137 | 137 | $this->parseResult( |
138 | 138 | $result[1][$idx], |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | preg_match_all('/(abstract|final)\s+('.$types.')\s+([\sa-z\d\\\\_,]+){|('.$types.')\s+([\sa-z\d\\\\_,]+){/ix', $code, $result, PREG_PATTERN_ORDER); |
153 | 153 | |
154 | - if(isset($result[0][0])) { |
|
154 | + if (isset($result[0][0])) { |
|
155 | 155 | return $result; |
156 | 156 | } |
157 | 157 | |
@@ -163,14 +163,14 @@ discard block |
||
163 | 163 | $result = array(); |
164 | 164 | preg_match_all('/namespace\s+([^;]+);/ix', $code, $result, PREG_PATTERN_ORDER); |
165 | 165 | |
166 | - if(isset($result[0][0])) { |
|
166 | + if (isset($result[0][0])) { |
|
167 | 167 | $this->namespace = trim($result[1][0]); |
168 | 168 | } |
169 | 169 | } |
170 | 170 | |
171 | 171 | private function parseResult(string $keyword, string $declaration, string $type, string $simpleType, string $simpleDeclaration) : void |
172 | 172 | { |
173 | - if(empty($keyword)) { |
|
173 | + if (empty($keyword)) { |
|
174 | 174 | $type = $simpleType; |
175 | 175 | $declaration = $simpleDeclaration; |
176 | 176 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public static function factory($path) : FileInfo |
52 | 52 | { |
53 | - if($path instanceof self) { |
|
53 | + if ($path instanceof self) { |
|
54 | 54 | return $path; |
55 | 55 | } |
56 | 56 | |
@@ -67,12 +67,12 @@ discard block |
||
67 | 67 | $pathString = AbstractPathInfo::type2string($path); |
68 | 68 | $key = $pathString.';'.static::class; |
69 | 69 | |
70 | - if(!isset(self::$infoCache[$key])) |
|
70 | + if (!isset(self::$infoCache[$key])) |
|
71 | 71 | { |
72 | 72 | $class = static::class; |
73 | 73 | $instance = new $class($pathString); |
74 | 74 | |
75 | - if(!$instance instanceof self) { |
|
75 | + if (!$instance instanceof self) { |
|
76 | 76 | throw new FileHelper_Exception( |
77 | 77 | 'Invalid class' |
78 | 78 | ); |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | { |
107 | 107 | parent::__construct($path); |
108 | 108 | |
109 | - if(!self::is_file($this->path)) |
|
109 | + if (!self::is_file($this->path)) |
|
110 | 110 | { |
111 | 111 | throw new FileHelper_Exception( |
112 | 112 | 'Not a file path', |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | $path = trim($path); |
122 | 122 | |
123 | - if(empty($path)) |
|
123 | + if (empty($path)) |
|
124 | 124 | { |
125 | 125 | return false; |
126 | 126 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | return is_file($path) || pathinfo($path, PATHINFO_EXTENSION) !== ''; |
129 | 129 | } |
130 | 130 | |
131 | - public function removeExtension(bool $keepPath=false) : string |
|
131 | + public function removeExtension(bool $keepPath = false) : string |
|
132 | 132 | { |
133 | - if(!$keepPath) |
|
133 | + if (!$keepPath) |
|
134 | 134 | { |
135 | 135 | return (string)pathinfo($this->getName(), PATHINFO_FILENAME); |
136 | 136 | } |
@@ -155,11 +155,11 @@ discard block |
||
155 | 155 | return $this->removeExtension(); |
156 | 156 | } |
157 | 157 | |
158 | - public function getExtension(bool $lowercase=true) : string |
|
158 | + public function getExtension(bool $lowercase = true) : string |
|
159 | 159 | { |
160 | 160 | $ext = (string)pathinfo($this->path, PATHINFO_EXTENSION); |
161 | 161 | |
162 | - if($lowercase) |
|
162 | + if ($lowercase) |
|
163 | 163 | { |
164 | 164 | $ext = mb_strtolower($ext); |
165 | 165 | } |
@@ -180,12 +180,12 @@ discard block |
||
180 | 180 | */ |
181 | 181 | public function delete() : FileInfo |
182 | 182 | { |
183 | - if(!$this->exists()) |
|
183 | + if (!$this->exists()) |
|
184 | 184 | { |
185 | 185 | return $this; |
186 | 186 | } |
187 | 187 | |
188 | - if(unlink($this->path)) |
|
188 | + if (unlink($this->path)) |
|
189 | 189 | { |
190 | 190 | return $this; |
191 | 191 | } |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | { |
213 | 213 | $target = $this->checkCopyPrerequisites($targetPath); |
214 | 214 | |
215 | - if(copy($this->path, (string)$target)) |
|
215 | + if (copy($this->path, (string)$target)) |
|
216 | 216 | { |
217 | 217 | return $target; |
218 | 218 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function getLineReader() : LineReader |
266 | 266 | { |
267 | - if($this->lineReader === null) |
|
267 | + if ($this->lineReader === null) |
|
268 | 268 | { |
269 | 269 | $this->lineReader = new LineReader($this); |
270 | 270 | } |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | |
284 | 284 | $result = file_get_contents($this->getPath()); |
285 | 285 | |
286 | - if($result !== false) { |
|
286 | + if ($result !== false) { |
|
287 | 287 | return $result; |
288 | 288 | } |
289 | 289 | |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function putContents(string $content) : FileInfo |
307 | 307 | { |
308 | - if($this->exists()) |
|
308 | + if ($this->exists()) |
|
309 | 309 | { |
310 | 310 | $this->requireWritable(); |
311 | 311 | } |
@@ -316,7 +316,7 @@ discard block |
||
316 | 316 | ->requireWritable(); |
317 | 317 | } |
318 | 318 | |
319 | - if(file_put_contents($this->path, $content) !== false) |
|
319 | + if (file_put_contents($this->path, $content) !== false) |
|
320 | 320 | { |
321 | 321 | return $this; |
322 | 322 | } |
@@ -346,7 +346,7 @@ discard block |
||
346 | 346 | */ |
347 | 347 | private function createFolder() : FileInfo |
348 | 348 | { |
349 | - if(!$this->exists()) |
|
349 | + if (!$this->exists()) |
|
350 | 350 | { |
351 | 351 | FolderInfo::factory($this->getFolderPath()) |
352 | 352 | ->create() |
@@ -21,7 +21,7 @@ |
||
21 | 21 | { |
22 | 22 | protected bool $value = false; |
23 | 23 | |
24 | - public function __construct(bool $value=false) |
|
24 | + public function __construct(bool $value = false) |
|
25 | 25 | { |
26 | 26 | $this->value = $value; |
27 | 27 | } |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | private function addFont(string $name) : FontFamily |
34 | 34 | { |
35 | - if(!in_array($name, $this->fonts, true)) |
|
35 | + if (!in_array($name, $this->fonts, true)) |
|
36 | 36 | { |
37 | 37 | $this->fonts[] = $name; |
38 | 38 | } |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $result = array(); |
55 | 55 | |
56 | - foreach($this->headers as $header) |
|
56 | + foreach ($this->headers as $header) |
|
57 | 57 | { |
58 | 58 | $result[] = $header->getMimeType(); |
59 | 59 | } |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | { |
69 | 69 | // we may be in a CLI environment where the headers |
70 | 70 | // are not populated. |
71 | - if(!isset($_SERVER['HTTP_ACCEPT'])) { |
|
71 | + if (!isset($_SERVER['HTTP_ACCEPT'])) { |
|
72 | 72 | return; |
73 | 73 | } |
74 | 74 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | $accept = array(); |
89 | 89 | |
90 | - foreach($tokens as $i => $term) |
|
90 | + foreach ($tokens as $i => $term) |
|
91 | 91 | { |
92 | 92 | $accept[] = $this->parseEntry($i, $term); |
93 | 93 | } |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | $quality = 0; |
110 | 110 | $params = array(); |
111 | 111 | |
112 | - if(strpos($mime, ';') !== false) |
|
112 | + if (strpos($mime, ';') !== false) |
|
113 | 113 | { |
114 | 114 | $parts = explode(';', $mime); |
115 | 115 | $mime = (string)array_shift($parts); |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | // like a URL query string if separated by ampersands; |
119 | 119 | $params = ConvertHelper::parseQueryString(implode('&', $parts)); |
120 | 120 | |
121 | - if(isset($params['q'])) |
|
121 | + if (isset($params['q'])) |
|
122 | 122 | { |
123 | 123 | $quality = (double)$params['q']; |
124 | 124 | } |
@@ -91,7 +91,7 @@ |
||
91 | 91 | */ |
92 | 92 | public function offsetSet($offset, $value) : void |
93 | 93 | { |
94 | - if(isset($this->data[$offset]) && gettype($this->data[$offset]) === gettype($value)) { |
|
94 | + if (isset($this->data[$offset]) && gettype($this->data[$offset]) === gettype($value)) { |
|
95 | 95 | $this->data[$offset] = $value; |
96 | 96 | } |
97 | 97 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | { |
31 | 31 | $pathString = AbstractPathInfo::type2string($path); |
32 | 32 | |
33 | - if(!isset(self::$infoCache[$pathString])) |
|
33 | + if (!isset(self::$infoCache[$pathString])) |
|
34 | 34 | { |
35 | 35 | self::$infoCache[$pathString] = new FolderInfo($pathString); |
36 | 36 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | { |
60 | 60 | parent::__construct($path); |
61 | 61 | |
62 | - if(!self::is_dir($this->path)) |
|
62 | + if (!self::is_dir($this->path)) |
|
63 | 63 | { |
64 | 64 | throw new FileHelper_Exception( |
65 | 65 | 'Not a folder', |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | { |
82 | 82 | $path = trim($path); |
83 | 83 | |
84 | - if($path === '' || $path === '.' || $path === '..') |
|
84 | + if ($path === '' || $path === '.' || $path === '..') |
|
85 | 85 | { |
86 | 86 | return false; |
87 | 87 | } |
88 | 88 | |
89 | - if(is_dir($path)) |
|
89 | + if (is_dir($path)) |
|
90 | 90 | { |
91 | 91 | return true; |
92 | 92 | } |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | */ |
105 | 105 | public function delete() : FolderInfo |
106 | 106 | { |
107 | - if(!$this->exists()) |
|
107 | + if (!$this->exists()) |
|
108 | 108 | { |
109 | 109 | return $this; |
110 | 110 | } |
111 | 111 | |
112 | - if(rmdir($this->path)) |
|
112 | + if (rmdir($this->path)) |
|
113 | 113 | { |
114 | 114 | return $this; |
115 | 115 | } |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | */ |
136 | 136 | public function create() : FolderInfo |
137 | 137 | { |
138 | - if(is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
138 | + if (is_dir($this->path) || mkdir($this->path, 0777, true) || is_dir($this->path)) |
|
139 | 139 | { |
140 | 140 | return $this; |
141 | 141 | } |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | return FileHelper::createFolder($this->getPath().'/'.$name); |
186 | 186 | } |
187 | 187 | |
188 | - public function saveFile(string $fileName, string $content='') : FileInfo |
|
188 | + public function saveFile(string $fileName, string $content = '') : FileInfo |
|
189 | 189 | { |
190 | 190 | return FileHelper::saveFile($this.'/'.$fileName, $content); |
191 | 191 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | * @return JSONFile |
198 | 198 | * @throws FileHelper_Exception |
199 | 199 | */ |
200 | - public function saveJSONFile(array $data, string $fileName, bool $pretty=false) : JSONFile |
|
200 | + public function saveJSONFile(array $data, string $fileName, bool $pretty = false) : JSONFile |
|
201 | 201 | { |
202 | 202 | return FileHelper::saveAsJSON($data, $this.'/'.$fileName, $pretty); |
203 | 203 | } |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * the vendor name, for example (Vendor\PackageName\Folder\Class). |
42 | 42 | * @return string|null The detected class name, or NULL otherwise. |
43 | 43 | */ |
44 | - public static function resolveClassName(string $legacyName, string $nsPrefix='') : ?string |
|
44 | + public static function resolveClassName(string $legacyName, string $nsPrefix = '') : ?string |
|
45 | 45 | { |
46 | 46 | $names = array( |
47 | 47 | str_replace('\\', '_', $legacyName), |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | $nsPrefix.'\\'.str_replace('_', '\\', $legacyName) |
50 | 50 | ); |
51 | 51 | |
52 | - foreach($names as $name) { |
|
52 | + foreach ($names as $name) { |
|
53 | 53 | if (class_exists($name)) { |
54 | 54 | return ltrim($name, '\\'); |
55 | 55 | } |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | * @return string |
69 | 69 | * @throws ClassNotExistsException |
70 | 70 | */ |
71 | - public static function requireResolvedClass(string $legacyName, string $nsPrefix='') : string |
|
71 | + public static function requireResolvedClass(string $legacyName, string $nsPrefix = '') : string |
|
72 | 72 | { |
73 | 73 | $class = self::resolveClassName($legacyName, $nsPrefix); |
74 | 74 | |
75 | - if($class !== null) |
|
75 | + if ($class !== null) |
|
76 | 76 | { |
77 | 77 | return $class; |
78 | 78 | } |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function requireClassExists(string $className) : void |
94 | 94 | { |
95 | - if(class_exists($className)) |
|
95 | + if (class_exists($className)) |
|
96 | 96 | { |
97 | 97 | return; |
98 | 98 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | self::requireClassExists($targetClass); |
118 | 118 | self::requireClassExists($extendsClass); |
119 | 119 | |
120 | - if(is_a($targetClass, $extendsClass, true)) |
|
120 | + if (is_a($targetClass, $extendsClass, true)) |
|
121 | 121 | { |
122 | 122 | return; |
123 | 123 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | * @throws ClassNotExistsException |
143 | 143 | * @throws ClassNotImplementsException |
144 | 144 | */ |
145 | - public static function requireObjectInstanceOf(string $class, object $object, int $errorCode=0) |
|
145 | + public static function requireObjectInstanceOf(string $class, object $object, int $errorCode = 0) |
|
146 | 146 | { |
147 | - if($object instanceof Throwable) |
|
147 | + if ($object instanceof Throwable) |
|
148 | 148 | { |
149 | 149 | throw new ClassNotExistsException( |
150 | 150 | $class, |
@@ -153,12 +153,12 @@ discard block |
||
153 | 153 | ); |
154 | 154 | } |
155 | 155 | |
156 | - if(!class_exists($class) && !interface_exists($class) && !trait_exists($class)) |
|
156 | + if (!class_exists($class) && !interface_exists($class) && !trait_exists($class)) |
|
157 | 157 | { |
158 | 158 | throw new ClassNotExistsException($class, $errorCode); |
159 | 159 | } |
160 | 160 | |
161 | - if(is_a($object, $class, true)) |
|
161 | + if (is_a($object, $class, true)) |
|
162 | 162 | { |
163 | 163 | return $object; |
164 | 164 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | public static function getClassLoader() : ClassLoader |
181 | 181 | { |
182 | - if(isset(self::$classLoader)) { |
|
182 | + if (isset(self::$classLoader)) { |
|
183 | 183 | return self::$classLoader; |
184 | 184 | } |
185 | 185 | |
@@ -193,14 +193,14 @@ discard block |
||
193 | 193 | |
194 | 194 | $autoloadFile = null; |
195 | 195 | |
196 | - foreach($paths as $path) |
|
196 | + foreach ($paths as $path) |
|
197 | 197 | { |
198 | - if(file_exists($path)) { |
|
198 | + if (file_exists($path)) { |
|
199 | 199 | $autoloadFile = $path; |
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
203 | - if($autoloadFile === null) { |
|
203 | + if ($autoloadFile === null) { |
|
204 | 204 | throw new ClassLoaderNotFoundException($paths); |
205 | 205 | } |
206 | 206 | |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | */ |
252 | 252 | private static function splitClass($subject) : array |
253 | 253 | { |
254 | - if(is_object($subject)) { |
|
254 | + if (is_object($subject)) { |
|
255 | 255 | $class = get_class($subject); |
256 | 256 | } else { |
257 | 257 | $class = $subject; |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @param bool $enabled |
107 | 107 | * @return $this |
108 | 108 | */ |
109 | - public function enableNormalizing(bool $enabled=true) : ConvertHelper_URLFinder |
|
109 | + public function enableNormalizing(bool $enabled = true) : ConvertHelper_URLFinder |
|
110 | 110 | { |
111 | 111 | $this->setOption('normalize', $enabled); |
112 | 112 | return $this; |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * @param bool $enabled |
119 | 119 | * @return $this |
120 | 120 | */ |
121 | - public function enableSorting(bool $enabled=true) : ConvertHelper_URLFinder |
|
121 | + public function enableSorting(bool $enabled = true) : ConvertHelper_URLFinder |
|
122 | 122 | { |
123 | 123 | $this->setOption('sorting', $enabled); |
124 | 124 | return $this; |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | * @param bool $include |
133 | 133 | * @return ConvertHelper_URLFinder |
134 | 134 | */ |
135 | - public function includeEmails(bool $include=true) : ConvertHelper_URLFinder |
|
135 | + public function includeEmails(bool $include = true) : ConvertHelper_URLFinder |
|
136 | 136 | { |
137 | 137 | $this->setOption('include-emails', $include); |
138 | 138 | return $this; |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | * @param bool $omit |
145 | 145 | * @return ConvertHelper_URLFinder |
146 | 146 | */ |
147 | - public function omitMailto(bool $omit=true) : ConvertHelper_URLFinder |
|
147 | + public function omitMailto(bool $omit = true) : ConvertHelper_URLFinder |
|
148 | 148 | { |
149 | 149 | $this->setOption('omit-mailto', $omit); |
150 | 150 | return $this; |
@@ -171,7 +171,7 @@ discard block |
||
171 | 171 | { |
172 | 172 | $line = $this->analyzeLine($line); |
173 | 173 | |
174 | - if($line !== null) { |
|
174 | + if ($line !== null) { |
|
175 | 175 | $keep[] = $line; |
176 | 176 | } |
177 | 177 | } |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | $line = trim($line, '.'); |
193 | 193 | |
194 | 194 | // Handle detecting an URI scheme |
195 | - if(strstr($line, ':') !== false) |
|
195 | + if (strstr($line, ':') !== false) |
|
196 | 196 | { |
197 | 197 | $scheme = URISchemes::detectScheme($line); |
198 | 198 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | // detect are email addresses and domain names. |
207 | 207 | |
208 | 208 | // No dot? Then it's certainly not a domain name. |
209 | - if(strstr($line, '.') === false) { |
|
209 | + if (strstr($line, '.') === false) { |
|
210 | 210 | return null; |
211 | 211 | } |
212 | 212 | |
@@ -224,10 +224,10 @@ discard block |
||
224 | 224 | { |
225 | 225 | $subject = stripslashes($subject); |
226 | 226 | |
227 | - foreach($this->detectors as $detector) |
|
227 | + foreach ($this->detectors as $detector) |
|
228 | 228 | { |
229 | 229 | // Avoid processing the string if it is not needed. |
230 | - if($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_BEFORE || !$detector->isValidFor($subject)) { |
|
230 | + if ($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_BEFORE || !$detector->isValidFor($subject)) { |
|
231 | 231 | continue; |
232 | 232 | } |
233 | 233 | |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | { |
249 | 249 | $detector = new $className(); |
250 | 250 | |
251 | - if($detector instanceof ConvertHelper_URLFinder_Detector) |
|
251 | + if ($detector instanceof ConvertHelper_URLFinder_Detector) |
|
252 | 252 | { |
253 | 253 | return $detector; |
254 | 254 | } |
@@ -275,12 +275,12 @@ discard block |
||
275 | 275 | |
276 | 276 | $result = $this->getItemsAsString($this->urls); |
277 | 277 | |
278 | - if($this->getBoolOption('include-emails')) |
|
278 | + if ($this->getBoolOption('include-emails')) |
|
279 | 279 | { |
280 | 280 | $result = array_merge($result, $this->getEmails()); |
281 | 281 | } |
282 | 282 | |
283 | - if($this->getBoolOption('sorting')) |
|
283 | + if ($this->getBoolOption('sorting')) |
|
284 | 284 | { |
285 | 285 | usort($result, function(string $a, string $b) { |
286 | 286 | return strnatcasecmp($a, $b); |
@@ -300,12 +300,12 @@ discard block |
||
300 | 300 | |
301 | 301 | $result = array(); |
302 | 302 | |
303 | - foreach($collection as $url => $info) { |
|
304 | - if($normalize) { |
|
303 | + foreach ($collection as $url => $info) { |
|
304 | + if ($normalize) { |
|
305 | 305 | $url = $info->getNormalized(); |
306 | 306 | } |
307 | 307 | |
308 | - if(!in_array($url, $result)) { |
|
308 | + if (!in_array($url, $result)) { |
|
309 | 309 | $result[] = $url; |
310 | 310 | } |
311 | 311 | } |
@@ -322,9 +322,9 @@ discard block |
||
322 | 322 | */ |
323 | 323 | private function initDetectors() : void |
324 | 324 | { |
325 | - foreach($this->enabledDetectorClasses as $className => $enabled) |
|
325 | + foreach ($this->enabledDetectorClasses as $className => $enabled) |
|
326 | 326 | { |
327 | - if($enabled) { |
|
327 | + if ($enabled) { |
|
328 | 328 | $this->detectors[] = $this->createDetector($className); |
329 | 329 | } |
330 | 330 | } |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | */ |
340 | 340 | private function parse() : void |
341 | 341 | { |
342 | - if($this->parsed) { |
|
342 | + if ($this->parsed) { |
|
343 | 343 | return; |
344 | 344 | } |
345 | 345 | |
@@ -350,11 +350,11 @@ discard block |
||
350 | 350 | |
351 | 351 | unset($this->subject); |
352 | 352 | |
353 | - foreach($this->matches as $match) |
|
353 | + foreach ($this->matches as $match) |
|
354 | 354 | { |
355 | 355 | $info = parseURL($match); |
356 | 356 | |
357 | - if($info->isEmail()) |
|
357 | + if ($info->isEmail()) |
|
358 | 358 | { |
359 | 359 | $this->emails[$this->filterEmailAddress($match)] = $info; |
360 | 360 | continue; |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @param bool $enable |
371 | 371 | * @return $this |
372 | 372 | */ |
373 | - public function enableHTMLAttributes(bool $enable=true) : ConvertHelper_URLFinder |
|
373 | + public function enableHTMLAttributes(bool $enable = true) : ConvertHelper_URLFinder |
|
374 | 374 | { |
375 | 375 | $this->enabledDetectorClasses[ConvertHelper_URLFinder_Detector_HTMLAttributes::class] = $enable; |
376 | 376 | return $this; |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | private function filterEmailAddress(string $email) : string |
387 | 387 | { |
388 | - if(stristr($email, 'mailto:') === false) { |
|
388 | + if (stristr($email, 'mailto:') === false) { |
|
389 | 389 | $email = 'mailto:'.$email; |
390 | 390 | } |
391 | 391 | |
@@ -407,14 +407,14 @@ discard block |
||
407 | 407 | foreach ($lines as $line) |
408 | 408 | { |
409 | 409 | $scheme = URISchemes::detectScheme($line); |
410 | - if($scheme !== null) { |
|
410 | + if ($scheme !== null) { |
|
411 | 411 | $this->matches[] = $line; |
412 | 412 | continue; |
413 | 413 | } |
414 | 414 | |
415 | 415 | $extension = $this->detectDomainExtension($line); |
416 | 416 | |
417 | - if($domains->nameExists($extension)) { |
|
417 | + if ($domains->nameExists($extension)) { |
|
418 | 418 | $this->matches[] = $line; |
419 | 419 | } |
420 | 420 | } |
@@ -433,9 +433,9 @@ discard block |
||
433 | 433 | |
434 | 434 | $subject = str_replace($remove, ' ', $subject); |
435 | 435 | |
436 | - foreach($this->detectors as $detector) |
|
436 | + foreach ($this->detectors as $detector) |
|
437 | 437 | { |
438 | - if($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_AFTER || !$detector->isValidFor($subject)) { |
|
438 | + if ($detector->getRunPosition() !== ConvertHelper_URLFinder_Detector::RUN_AFTER || !$detector->isValidFor($subject)) { |
|
439 | 439 | continue; |
440 | 440 | } |
441 | 441 | |
@@ -458,8 +458,8 @@ discard block |
||
458 | 458 | $boundaries = array('/', '?'); |
459 | 459 | |
460 | 460 | // Remove the path or query parts to access the domain extension only |
461 | - foreach($boundaries as $boundary) { |
|
462 | - if(strstr($url, $boundary)) { |
|
461 | + foreach ($boundaries as $boundary) { |
|
462 | + if (strstr($url, $boundary)) { |
|
463 | 463 | $parts = explode($boundary, $url); |
464 | 464 | $url = array_shift($parts); |
465 | 465 | break; |
@@ -484,16 +484,16 @@ discard block |
||
484 | 484 | |
485 | 485 | $result = $this->getItemsAsString($this->emails); |
486 | 486 | |
487 | - if($this->getBoolOption('omit-mailto')) { |
|
487 | + if ($this->getBoolOption('omit-mailto')) { |
|
488 | 488 | $keep = array(); |
489 | - foreach($result as $email) { |
|
489 | + foreach ($result as $email) { |
|
490 | 490 | $keep[] = str_replace('mailto:', '', $email); |
491 | 491 | } |
492 | 492 | |
493 | 493 | $result = $keep; |
494 | 494 | } |
495 | 495 | |
496 | - if($this->getBoolOption('sorting')) |
|
496 | + if ($this->getBoolOption('sorting')) |
|
497 | 497 | { |
498 | 498 | usort($result, function(string $a, string $b) { |
499 | 499 | return strnatcasecmp($a, $b); |
@@ -515,16 +515,16 @@ discard block |
||
515 | 515 | $result = array(); |
516 | 516 | $normalize = $this->getBoolOption('normalize'); |
517 | 517 | |
518 | - foreach($this->urls as $url => $info) |
|
518 | + foreach ($this->urls as $url => $info) |
|
519 | 519 | { |
520 | - if($normalize) { |
|
520 | + if ($normalize) { |
|
521 | 521 | $url = $info->getNormalized(); |
522 | 522 | } |
523 | 523 | |
524 | 524 | $result[$url] = $info; |
525 | 525 | } |
526 | 526 | |
527 | - if($this->getBoolOption('sorting')) |
|
527 | + if ($this->getBoolOption('sorting')) |
|
528 | 528 | { |
529 | 529 | ksort($result); |
530 | 530 | } |