@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | ->t('Message:') |
39 | 39 | ->add($this->info->getMessage()); |
40 | 40 | |
41 | - if($this->developerInfo) |
|
41 | + if ($this->developerInfo) |
|
42 | 42 | { |
43 | 43 | $message |
44 | 44 | ->eol() |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | ->add($finalCall->toString()); |
47 | 47 | } |
48 | 48 | |
49 | - if($this->developerInfo && $this->info->hasDetails()) |
|
49 | + if ($this->developerInfo && $this->info->hasDetails()) |
|
50 | 50 | { |
51 | 51 | $message |
52 | 52 | ->t('Developer details:') |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | ->add($this->info->getDetails()); |
55 | 55 | } |
56 | 56 | |
57 | - if($this->info->hasPrevious()) |
|
57 | + if ($this->info->hasPrevious()) |
|
58 | 58 | { |
59 | 59 | $message |
60 | 60 | ->eol() |
@@ -19,8 +19,8 @@ discard block |
||
19 | 19 | public function toString() : string |
20 | 20 | { |
21 | 21 | return |
22 | - $this->renderMessage() . |
|
23 | - $this->renderCalls() . |
|
22 | + $this->renderMessage(). |
|
23 | + $this->renderCalls(). |
|
24 | 24 | $this->renderPrevious(); |
25 | 25 | } |
26 | 26 | |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | |
34 | 34 | if ($this->info->hasCode()) |
35 | 35 | { |
36 | - $string .= ' #' . $this->info->getCode(); |
|
36 | + $string .= ' #'.$this->info->getCode(); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | $string .= |
40 | - ': ' . |
|
41 | - $this->info->getMessage() . |
|
40 | + ': '. |
|
41 | + $this->info->getMessage(). |
|
42 | 42 | PHP_EOL; |
43 | 43 | |
44 | 44 | return $string; |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | foreach ($calls as $call) |
57 | 57 | { |
58 | - $string .= $call->toString() . PHP_EOL; |
|
58 | + $string .= $call->toString().PHP_EOL; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return $string; |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | } |
74 | 74 | |
75 | 75 | return |
76 | - PHP_EOL . |
|
77 | - PHP_EOL . |
|
78 | - 'Previous error:' . |
|
79 | - PHP_EOL . |
|
80 | - PHP_EOL . |
|
76 | + PHP_EOL. |
|
77 | + PHP_EOL. |
|
78 | + 'Previous error:'. |
|
79 | + PHP_EOL. |
|
80 | + PHP_EOL. |
|
81 | 81 | $this->info->getPrevious()->toString(); |
82 | 82 | } |
83 | 83 | } |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | 'WriteThreshold' => 100 |
39 | 39 | ); |
40 | 40 | |
41 | - /** |
|
42 | - * @var string |
|
43 | - */ |
|
41 | + /** |
|
42 | + * @var string |
|
43 | + */ |
|
44 | 44 | protected $file; |
45 | 45 | |
46 | - /** |
|
47 | - * @var ZipArchive|NULL |
|
48 | - */ |
|
46 | + /** |
|
47 | + * @var ZipArchive|NULL |
|
48 | + */ |
|
49 | 49 | protected $zip; |
50 | 50 | |
51 | 51 | public function __construct(string $targetFile) |
@@ -53,35 +53,35 @@ discard block |
||
53 | 53 | $this->file = $targetFile; |
54 | 54 | } |
55 | 55 | |
56 | - /** |
|
57 | - * Sets an option, among the available options: |
|
58 | - * |
|
59 | - * <ul> |
|
60 | - * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
61 | - * </ul> |
|
62 | - * |
|
63 | - * @param string $name |
|
64 | - * @param mixed $value |
|
65 | - * @return ZIPHelper |
|
66 | - */ |
|
56 | + /** |
|
57 | + * Sets an option, among the available options: |
|
58 | + * |
|
59 | + * <ul> |
|
60 | + * <li>WriteThreshold: The amount of files to add before the zip is automatically written to disk and re-opened to release the file handles. Set to 0 to disable.</li> |
|
61 | + * </ul> |
|
62 | + * |
|
63 | + * @param string $name |
|
64 | + * @param mixed $value |
|
65 | + * @return ZIPHelper |
|
66 | + */ |
|
67 | 67 | public function setOption(string $name, $value) : ZIPHelper |
68 | 68 | { |
69 | 69 | $this->options[$name] = $value; |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * Adds a file to the zip. By default, the file is stored |
|
75 | - * with the same name in the root of the zip. Use the optional |
|
76 | - * parameter to change the location in the zip. |
|
77 | - * |
|
78 | - * @param string $filePath |
|
79 | - * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
80 | - * @throws ZIPHelper_Exception |
|
81 | - * @return bool |
|
82 | - * |
|
83 | - * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
84 | - */ |
|
73 | + /** |
|
74 | + * Adds a file to the zip. By default, the file is stored |
|
75 | + * with the same name in the root of the zip. Use the optional |
|
76 | + * parameter to change the location in the zip. |
|
77 | + * |
|
78 | + * @param string $filePath |
|
79 | + * @param string|null $zipPath If no path is specified, file will be added with the same name in the ZIP's root. |
|
80 | + * @throws ZIPHelper_Exception |
|
81 | + * @return bool |
|
82 | + * |
|
83 | + * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
|
84 | + */ |
|
85 | 85 | public function addFile(string $filePath, ?string $zipPath=null) : bool |
86 | 86 | { |
87 | 87 | $this->open(); |
@@ -289,14 +289,14 @@ discard block |
||
289 | 289 | return $this; |
290 | 290 | } |
291 | 291 | |
292 | - /** |
|
293 | - * Extracts all files and folders from the zip to the |
|
294 | - * target folder. If no folder is specified, the files |
|
295 | - * are extracted into the same folder as the zip itself. |
|
296 | - * |
|
297 | - * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
|
298 | - * @return boolean |
|
299 | - */ |
|
292 | + /** |
|
293 | + * Extracts all files and folders from the zip to the |
|
294 | + * target folder. If no folder is specified, the files |
|
295 | + * are extracted into the same folder as the zip itself. |
|
296 | + * |
|
297 | + * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
|
298 | + * @return boolean |
|
299 | + */ |
|
300 | 300 | public function extractAll(?string $outputFolder=null) : bool |
301 | 301 | { |
302 | 302 | if(empty($outputFolder)) { |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | return $this->zip->extractTo($outputFolder); |
309 | 309 | } |
310 | 310 | |
311 | - /** |
|
312 | - * @return ZipArchive |
|
313 | - */ |
|
311 | + /** |
|
312 | + * @return ZipArchive |
|
313 | + */ |
|
314 | 314 | public function getArchive() : ZipArchive |
315 | 315 | { |
316 | 316 | $this->open(); |
@@ -318,14 +318,14 @@ discard block |
||
318 | 318 | return $this->zip; |
319 | 319 | } |
320 | 320 | |
321 | - /** |
|
322 | - * JSON encodes the specified data and adds the json as |
|
323 | - * a file in the ZIP archive. |
|
324 | - * |
|
325 | - * @param mixed $data |
|
326 | - * @param string $zipPath |
|
327 | - * @return boolean |
|
328 | - */ |
|
321 | + /** |
|
322 | + * JSON encodes the specified data and adds the json as |
|
323 | + * a file in the ZIP archive. |
|
324 | + * |
|
325 | + * @param mixed $data |
|
326 | + * @param string $zipPath |
|
327 | + * @return boolean |
|
328 | + */ |
|
329 | 329 | public function addJSON($data, string $zipPath) : bool |
330 | 330 | { |
331 | 331 | return $this->addString( |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | |
33 | 33 | public const ERROR_OPENING_ZIP_FILE = 338003; |
34 | 34 | |
35 | - public const ERROR_CANNOT_SAVE_FILE_TO_DISK =338004; |
|
35 | + public const ERROR_CANNOT_SAVE_FILE_TO_DISK = 338004; |
|
36 | 36 | |
37 | 37 | protected $options = array( |
38 | 38 | 'WriteThreshold' => 100 |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * |
83 | 83 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
84 | 84 | */ |
85 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
85 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
86 | 86 | { |
87 | 87 | $this->open(); |
88 | 88 | |
@@ -135,16 +135,16 @@ discard block |
||
135 | 135 | */ |
136 | 136 | protected function open() : void |
137 | 137 | { |
138 | - if($this->open) { |
|
138 | + if ($this->open) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | 141 | |
142 | - if(!isset($this->zip)) { |
|
142 | + if (!isset($this->zip)) { |
|
143 | 143 | $this->zip = new ZipArchive(); |
144 | 144 | } |
145 | 145 | |
146 | 146 | $flag = null; |
147 | - if(!file_exists($this->file)) { |
|
147 | + if (!file_exists($this->file)) { |
|
148 | 148 | $flag = ZipArchive::CREATE; |
149 | 149 | } |
150 | 150 | |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | { |
188 | 188 | $this->fileTracker++; |
189 | 189 | |
190 | - if($this->options['WriteThreshold'] < 1) { |
|
190 | + if ($this->options['WriteThreshold'] < 1) { |
|
191 | 191 | return; |
192 | 192 | } |
193 | 193 | |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | |
201 | 201 | protected function close() : void |
202 | 202 | { |
203 | - if(!$this->open) { |
|
203 | + if (!$this->open) { |
|
204 | 204 | return; |
205 | 205 | } |
206 | 206 | |
@@ -209,8 +209,8 @@ discard block |
||
209 | 209 | throw new ZIPHelper_Exception( |
210 | 210 | 'Could not save ZIP file to disk', |
211 | 211 | sprintf( |
212 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
213 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
212 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
213 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
214 | 214 | 'or trying to save to a directory that does not exist.', |
215 | 215 | $this->file |
216 | 216 | ), |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | $this->open(); |
227 | 227 | |
228 | - if($this->countFiles() < 1) |
|
228 | + if ($this->countFiles() < 1) |
|
229 | 229 | { |
230 | 230 | throw new ZIPHelper_Exception( |
231 | 231 | 'No files in the zip file', |
@@ -251,18 +251,18 @@ discard block |
||
251 | 251 | * @throws ZIPHelper_Exception |
252 | 252 | * @return string The file name that was sent (useful in case none was specified). |
253 | 253 | */ |
254 | - public function download(?string $fileName=null) : string |
|
254 | + public function download(?string $fileName = null) : string |
|
255 | 255 | { |
256 | 256 | $this->save(); |
257 | 257 | |
258 | - if(empty($fileName)) |
|
258 | + if (empty($fileName)) |
|
259 | 259 | { |
260 | 260 | $fileName = basename($this->file); |
261 | 261 | } |
262 | 262 | |
263 | 263 | header('Content-type: application/zip'); |
264 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
265 | - header('Content-length: ' . filesize($this->file)); |
|
264 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
265 | + header('Content-length: '.filesize($this->file)); |
|
266 | 266 | header('Pragma: no-cache'); |
267 | 267 | header('Expires: 0'); |
268 | 268 | readfile($this->file); |
@@ -280,7 +280,7 @@ discard block |
||
280 | 280 | * @throws ZIPHelper_Exception |
281 | 281 | * @see ZIPHelper::download() |
282 | 282 | */ |
283 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
283 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
284 | 284 | { |
285 | 285 | $this->download($fileName); |
286 | 286 | |
@@ -297,9 +297,9 @@ discard block |
||
297 | 297 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
298 | 298 | * @return boolean |
299 | 299 | */ |
300 | - public function extractAll(?string $outputFolder=null) : bool |
|
300 | + public function extractAll(?string $outputFolder = null) : bool |
|
301 | 301 | { |
302 | - if(empty($outputFolder)) { |
|
302 | + if (empty($outputFolder)) { |
|
303 | 303 | $outputFolder = dirname($this->file); |
304 | 304 | } |
305 | 305 |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | * @param bool $lowercase |
62 | 62 | * @return Transliteration |
63 | 63 | */ |
64 | - public function setLowercase(bool $lowercase=true) : Transliteration |
|
64 | + public function setLowercase(bool $lowercase = true) : Transliteration |
|
65 | 65 | { |
66 | 66 | $this->setOption(self::OPTION_LOWER_CASE, $lowercase); |
67 | 67 | |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | |
100 | 100 | $result = implode('', $keep); |
101 | 101 | |
102 | - while (strpos($result, $space . $space) !== false) { |
|
103 | - $result = str_replace($space . $space, $space, $result); |
|
102 | + while (strpos($result, $space.$space) !== false) { |
|
103 | + $result = str_replace($space.$space, $space, $result); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | $result = trim($result, $space); |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|number|StringBuilder_Interface|NULL $content |
30 | 30 | * @return HTMLTag |
31 | 31 | */ |
32 | - public static function anchor(string $url, $content=null) : HTMLTag |
|
32 | + public static function anchor(string $url, $content = null) : HTMLTag |
|
33 | 33 | { |
34 | 34 | return HTMLTag::create('a') |
35 | 35 | ->href($url) |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @param string|number|StringBuilder_Interface|NULL $content |
47 | 47 | * @return HTMLTag |
48 | 48 | */ |
49 | - public static function div($content=null) : HTMLTag |
|
49 | + public static function div($content = null) : HTMLTag |
|
50 | 50 | { |
51 | 51 | return HTMLTag::create('div')->setContent($content); |
52 | 52 | } |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | * @param string|number|StringBuilder_Interface|NULL $content |
56 | 56 | * @return HTMLTag |
57 | 57 | */ |
58 | - public static function p($content=null) : HTMLTag |
|
58 | + public static function p($content = null) : HTMLTag |
|
59 | 59 | { |
60 | 60 | return HTMLTag::create('p')->setContent($content); |
61 | 61 | } |
@@ -17,21 +17,20 @@ discard block |
||
17 | 17 | * @package Application Utils |
18 | 18 | * @subpackage ConvertHelper |
19 | 19 | * @author Sebastian Mordziol <[email protected]> |
20 | - |
|
21 | 20 | * @see ConvertHelper::interval2string() |
22 | 21 | */ |
23 | 22 | class ConvertHelper_IntervalConverter |
24 | 23 | { |
25 | 24 | public const ERROR_MISSING_TRANSLATION = 43501; |
26 | 25 | |
27 | - /** |
|
28 | - * @var array<string,string>|NULL |
|
29 | - */ |
|
26 | + /** |
|
27 | + * @var array<string,string>|NULL |
|
28 | + */ |
|
30 | 29 | protected static $texts = null; |
31 | 30 | |
32 | - /** |
|
33 | - * @var string[] |
|
34 | - */ |
|
31 | + /** |
|
32 | + * @var string[] |
|
33 | + */ |
|
35 | 34 | protected $tokens = array('y', 'm', 'd', 'h', 'i', 's'); |
36 | 35 | |
37 | 36 | public function __construct() |
@@ -41,25 +40,25 @@ discard block |
||
41 | 40 | } |
42 | 41 | } |
43 | 42 | |
44 | - /** |
|
45 | - * Called whenever the application locale has changed, |
|
46 | - * to reset the internal translation cache. |
|
47 | - */ |
|
43 | + /** |
|
44 | + * Called whenever the application locale has changed, |
|
45 | + * to reset the internal translation cache. |
|
46 | + */ |
|
48 | 47 | public function handle_localeChanged() : void |
49 | 48 | { |
50 | 49 | self::$texts = null; |
51 | 50 | } |
52 | 51 | |
53 | - /** |
|
54 | - * Converts the specified interval to a human-readable |
|
55 | - * string, e.g. "2 hours and 4 minutes". |
|
56 | - * |
|
57 | - * @param \DateInterval $interval |
|
58 | - * @return string |
|
59 | - * @throws ConvertHelper_Exception |
|
60 | - * |
|
61 | - * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
62 | - */ |
|
52 | + /** |
|
53 | + * Converts the specified interval to a human-readable |
|
54 | + * string, e.g. "2 hours and 4 minutes". |
|
55 | + * |
|
56 | + * @param \DateInterval $interval |
|
57 | + * @return string |
|
58 | + * @throws ConvertHelper_Exception |
|
59 | + * |
|
60 | + * @see ConvertHelper_IntervalConverter::ERROR_MISSING_TRANSLATION |
|
61 | + */ |
|
63 | 62 | public function toString(\DateInterval $interval) : string |
64 | 63 | { |
65 | 64 | $this->initTexts(); |
@@ -88,14 +87,14 @@ discard block |
||
88 | 87 | return t('%1$s and %2$s', implode(', ', $parts), $last); |
89 | 88 | } |
90 | 89 | |
91 | - /** |
|
92 | - * Translates the selected time token, e.g. "y" (for year). |
|
93 | - * |
|
94 | - * @param string $token |
|
95 | - * @param ConvertHelper_DateInterval $interval |
|
96 | - * @throws ConvertHelper_Exception |
|
97 | - * @return string |
|
98 | - */ |
|
90 | + /** |
|
91 | + * Translates the selected time token, e.g. "y" (for year). |
|
92 | + * |
|
93 | + * @param string $token |
|
94 | + * @param ConvertHelper_DateInterval $interval |
|
95 | + * @throws ConvertHelper_Exception |
|
96 | + * @return string |
|
97 | + */ |
|
99 | 98 | protected function translateToken(string $token, ConvertHelper_DateInterval $interval) : string |
100 | 99 | { |
101 | 100 | $value = $interval->getToken($token); |
@@ -123,13 +122,13 @@ discard block |
||
123 | 122 | ); |
124 | 123 | } |
125 | 124 | |
126 | - /** |
|
127 | - * Resolves all time tokens that need to be translated in |
|
128 | - * the subject interval, depending on its length. |
|
129 | - * |
|
130 | - * @param ConvertHelper_DateInterval $interval |
|
131 | - * @return string[] |
|
132 | - */ |
|
125 | + /** |
|
126 | + * Resolves all time tokens that need to be translated in |
|
127 | + * the subject interval, depending on its length. |
|
128 | + * |
|
129 | + * @param ConvertHelper_DateInterval $interval |
|
130 | + * @return string[] |
|
131 | + */ |
|
133 | 132 | protected function resolveTokens(ConvertHelper_DateInterval $interval) : array |
134 | 133 | { |
135 | 134 | $offset = 0; |
@@ -147,9 +146,9 @@ discard block |
||
147 | 146 | return array(); |
148 | 147 | } |
149 | 148 | |
150 | - /** |
|
151 | - * Initializes the translateable strings. |
|
152 | - */ |
|
149 | + /** |
|
150 | + * Initializes the translateable strings. |
|
151 | + */ |
|
153 | 152 | protected function initTexts() : void |
154 | 153 | { |
155 | 154 | if(isset(self::$texts)) { |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | |
37 | 37 | public function __construct() |
38 | 38 | { |
39 | - if(class_exists('\AppLocalize\Localization')) { |
|
39 | + if (class_exists('\AppLocalize\Localization')) { |
|
40 | 40 | \AppLocalize\Localization::onLocaleChanged(array($this, 'handle_localeChanged')); |
41 | 41 | } |
42 | 42 | } |
@@ -69,17 +69,17 @@ discard block |
||
69 | 69 | $keep = $this->resolveTokens($interval); |
70 | 70 | |
71 | 71 | $parts = array(); |
72 | - foreach($keep as $token) |
|
72 | + foreach ($keep as $token) |
|
73 | 73 | { |
74 | 74 | $value = $interval->getToken($token); |
75 | - if($value <= 0) { |
|
75 | + if ($value <= 0) { |
|
76 | 76 | continue; |
77 | 77 | } |
78 | 78 | |
79 | 79 | $parts[] = $this->translateToken($token, $interval); |
80 | 80 | } |
81 | 81 | |
82 | - if(count($parts) == 1) { |
|
82 | + if (count($parts) == 1) { |
|
83 | 83 | return $parts[0]; |
84 | 84 | } |
85 | 85 | |
@@ -101,10 +101,10 @@ discard block |
||
101 | 101 | $value = $interval->getToken($token); |
102 | 102 | |
103 | 103 | $suffix = 'p'; |
104 | - if($value == 1) { $suffix = 's'; } |
|
104 | + if ($value == 1) { $suffix = 's'; } |
|
105 | 105 | $token .= $suffix; |
106 | 106 | |
107 | - if(!isset(self::$texts[$token])) |
|
107 | + if (!isset(self::$texts[$token])) |
|
108 | 108 | { |
109 | 109 | throw new ConvertHelper_Exception( |
110 | 110 | 'Missing interval translation', |
@@ -134,9 +134,9 @@ discard block |
||
134 | 134 | { |
135 | 135 | $offset = 0; |
136 | 136 | |
137 | - foreach($this->tokens as $token) |
|
137 | + foreach ($this->tokens as $token) |
|
138 | 138 | { |
139 | - if($interval->getToken($token) > 0) |
|
139 | + if ($interval->getToken($token) > 0) |
|
140 | 140 | { |
141 | 141 | return array_slice($this->tokens, $offset); |
142 | 142 | } |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | protected function initTexts() : void |
154 | 154 | { |
155 | - if(isset(self::$texts)) { |
|
155 | + if (isset(self::$texts)) { |
|
156 | 156 | return; |
157 | 157 | } |
158 | 158 |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | { |
47 | 47 | public const ERROR_FAILED_CONVERTING_TO_JSON = 37901; |
48 | 48 | |
49 | - /** |
|
50 | - * @var SimpleXMLElement |
|
51 | - */ |
|
49 | + /** |
|
50 | + * @var SimpleXMLElement |
|
51 | + */ |
|
52 | 52 | protected $xml; |
53 | 53 | |
54 | - /** |
|
55 | - * @var string|NULL |
|
56 | - */ |
|
54 | + /** |
|
55 | + * @var string|NULL |
|
56 | + */ |
|
57 | 57 | protected $json; |
58 | 58 | |
59 | 59 | protected function __construct(SimpleXMLElement $element) |
@@ -86,34 +86,34 @@ discard block |
||
86 | 86 | return self::fromElement(new SimpleXMLElement($xmlString)); |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
91 | - * |
|
92 | - * @param SimpleXMLElement $element |
|
93 | - * @return XMLHelper_Converter |
|
94 | - */ |
|
89 | + /** |
|
90 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
91 | + * |
|
92 | + * @param SimpleXMLElement $element |
|
93 | + * @return XMLHelper_Converter |
|
94 | + */ |
|
95 | 95 | public static function fromElement(SimpleXMLElement $element) : XMLHelper_Converter |
96 | 96 | { |
97 | 97 | return new XMLHelper_Converter($element); |
98 | 98 | } |
99 | 99 | |
100 | - /** |
|
101 | - * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
102 | - * |
|
103 | - * @param DOMElement $element |
|
104 | - * @return XMLHelper_Converter |
|
105 | - */ |
|
100 | + /** |
|
101 | + * Factory method: creates a converter from an existing SimpleXMLElement instance. |
|
102 | + * |
|
103 | + * @param DOMElement $element |
|
104 | + * @return XMLHelper_Converter |
|
105 | + */ |
|
106 | 106 | public static function fromDOMElement(DOMElement $element) : XMLHelper_Converter |
107 | 107 | { |
108 | 108 | return new XMLHelper_Converter(simplexml_import_dom($element)); |
109 | 109 | } |
110 | 110 | |
111 | - /** |
|
112 | - * Converts the XML to JSON. |
|
113 | - * |
|
114 | - * @return string |
|
115 | - * @throws XMLHelper_Exception|JsonException |
|
116 | - */ |
|
111 | + /** |
|
112 | + * Converts the XML to JSON. |
|
113 | + * |
|
114 | + * @return string |
|
115 | + * @throws XMLHelper_Exception|JsonException |
|
116 | + */ |
|
117 | 117 | public function toJSON() : string |
118 | 118 | { |
119 | 119 | if (isset($this->json)) |
@@ -146,11 +146,11 @@ discard block |
||
146 | 146 | } |
147 | 147 | } |
148 | 148 | |
149 | - /** |
|
150 | - * Converts the XML to an associative array. |
|
151 | - * @return array |
|
152 | - * @throws XMLHelper_Exception|JsonException |
|
153 | - */ |
|
149 | + /** |
|
150 | + * Converts the XML to an associative array. |
|
151 | + * @return array |
|
152 | + * @throws XMLHelper_Exception|JsonException |
|
153 | + */ |
|
154 | 154 | public function toArray() : array |
155 | 155 | { |
156 | 156 | $json = $this->toJSON(); |
@@ -130,8 +130,7 @@ |
||
130 | 130 | unset($this->xml); |
131 | 131 | |
132 | 132 | return $this->json; |
133 | - } |
|
134 | - catch (Exception $e) |
|
133 | + } catch (Exception $e) |
|
135 | 134 | { |
136 | 135 | throw new XMLHelper_Exception( |
137 | 136 | 'Could not convert the XML source to JSON', |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | |
43 | 43 | public const REGEX_MD5 = '/^[a-f0-9]{32}$/i'; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string |
|
47 | - * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | - */ |
|
45 | + /** |
|
46 | + * @var string |
|
47 | + * @see https://en.wikipedia.org/wiki/Email_address#Local-part |
|
48 | + */ |
|
49 | 49 | public const REGEX_EMAIL = '/[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&\'*+\/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?/i'; |
50 | 50 | |
51 | 51 | public const REGEX_PHONE = '/\A[+0-9][0-9 +\-()]+\z/m'; |
@@ -97,14 +97,14 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public const REGEX_IS_HTML = '%<{0,1}[a-z\/][\s\S]*>|<[a-z\/][\s\S]*>{0,1}%i'; |
99 | 99 | |
100 | - /** |
|
101 | - * Hexadecimal color codes. Allows the following formats: |
|
102 | - * |
|
103 | - * FFFFFF |
|
104 | - * FFF |
|
105 | - * |
|
106 | - * @var string |
|
107 | - */ |
|
100 | + /** |
|
101 | + * Hexadecimal color codes. Allows the following formats: |
|
102 | + * |
|
103 | + * FFFFFF |
|
104 | + * FFF |
|
105 | + * |
|
106 | + * @var string |
|
107 | + */ |
|
108 | 108 | public const REGEX_HEX_COLOR_CODE = '/\A(?:[0-9a-fA-F]{6}|[0-9a-fA-F]{3})\z/iU'; |
109 | 109 | |
110 | 110 | /** |
@@ -38,17 +38,17 @@ discard block |
||
38 | 38 | */ |
39 | 39 | protected $classes = array(); |
40 | 40 | |
41 | - /** |
|
42 | - * The namespace detected in the file, if any. |
|
43 | - * @var string |
|
44 | - */ |
|
41 | + /** |
|
42 | + * The namespace detected in the file, if any. |
|
43 | + * @var string |
|
44 | + */ |
|
45 | 45 | protected $namespace = ''; |
46 | 46 | |
47 | - /** |
|
48 | - * @param string $path The path to the PHP file to parse. |
|
49 | - * @throws FileHelper_Exception |
|
50 | - * @see FileHelper::findPHPClasses() |
|
51 | - */ |
|
47 | + /** |
|
48 | + * @param string $path The path to the PHP file to parse. |
|
49 | + * @throws FileHelper_Exception |
|
50 | + * @see FileHelper::findPHPClasses() |
|
51 | + */ |
|
52 | 52 | public function __construct(string $path) |
53 | 53 | { |
54 | 54 | $this->path = realpath($path); |
@@ -68,58 +68,58 @@ discard block |
||
68 | 68 | $this->parseFile(); |
69 | 69 | } |
70 | 70 | |
71 | - /** |
|
72 | - * The name of the namespace of the classes in the file, if any. |
|
73 | - * @return string |
|
74 | - */ |
|
71 | + /** |
|
72 | + * The name of the namespace of the classes in the file, if any. |
|
73 | + * @return string |
|
74 | + */ |
|
75 | 75 | public function getNamespace() : string |
76 | 76 | { |
77 | 77 | return $this->namespace; |
78 | 78 | } |
79 | 79 | |
80 | - /** |
|
81 | - * Whether the file contains a namespace. |
|
82 | - * @return bool |
|
83 | - */ |
|
80 | + /** |
|
81 | + * Whether the file contains a namespace. |
|
82 | + * @return bool |
|
83 | + */ |
|
84 | 84 | public function hasNamespace() : bool |
85 | 85 | { |
86 | 86 | return !empty($this->namespace); |
87 | 87 | } |
88 | 88 | |
89 | - /** |
|
90 | - * The absolute path to the file. |
|
91 | - * @return string |
|
92 | - */ |
|
89 | + /** |
|
90 | + * The absolute path to the file. |
|
91 | + * @return string |
|
92 | + */ |
|
93 | 93 | public function getPath() : string |
94 | 94 | { |
95 | 95 | return $this->path; |
96 | 96 | } |
97 | 97 | |
98 | - /** |
|
99 | - * Whether any classes were found in the file. |
|
100 | - * @return bool |
|
101 | - */ |
|
98 | + /** |
|
99 | + * Whether any classes were found in the file. |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | 102 | public function hasClasses() : bool |
103 | 103 | { |
104 | 104 | return !empty($this->classes); |
105 | 105 | } |
106 | 106 | |
107 | - /** |
|
108 | - * The names of the classes that were found in the file (with namespace if any). |
|
109 | - * @return string[] |
|
110 | - */ |
|
107 | + /** |
|
108 | + * The names of the classes that were found in the file (with namespace if any). |
|
109 | + * @return string[] |
|
110 | + */ |
|
111 | 111 | public function getClassNames() : array |
112 | 112 | { |
113 | 113 | return array_keys($this->classes); |
114 | 114 | } |
115 | 115 | |
116 | - /** |
|
117 | - * Retrieves all classes that were detected in the file, |
|
118 | - * which can be used to retrieve more information about |
|
119 | - * them. |
|
120 | - * |
|
121 | - * @return FileHelper_PHPClassInfo_Class[] |
|
122 | - */ |
|
116 | + /** |
|
117 | + * Retrieves all classes that were detected in the file, |
|
118 | + * which can be used to retrieve more information about |
|
119 | + * them. |
|
120 | + * |
|
121 | + * @return FileHelper_PHPClassInfo_Class[] |
|
122 | + */ |
|
123 | 123 | public function getClasses() : array |
124 | 124 | { |
125 | 125 | return array_values($this->classes); |
@@ -165,13 +165,13 @@ discard block |
||
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
168 | - /** |
|
169 | - * Strips all whitespace from the string, replacing it with |
|
170 | - * regular spaces (newlines, tabs, etc.). |
|
171 | - * |
|
172 | - * @param string $string |
|
173 | - * @return string |
|
174 | - */ |
|
168 | + /** |
|
169 | + * Strips all whitespace from the string, replacing it with |
|
170 | + * regular spaces (newlines, tabs, etc.). |
|
171 | + * |
|
172 | + * @param string $string |
|
173 | + * @return string |
|
174 | + */ |
|
175 | 175 | protected function stripWhitespace(string $string) : string |
176 | 176 | { |
177 | 177 | return preg_replace('/[\s]/', ' ', $string); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | { |
54 | 54 | $this->path = realpath($path); |
55 | 55 | |
56 | - if($this->path === false) |
|
56 | + if ($this->path === false) |
|
57 | 57 | { |
58 | 58 | throw new FileHelper_Exception( |
59 | 59 | 'Cannot extract file information: file not found.', |
@@ -131,25 +131,25 @@ discard block |
||
131 | 131 | |
132 | 132 | $result = array(); |
133 | 133 | preg_match_all('/namespace[\s]+([^;]+);/six', $code, $result, PREG_PATTERN_ORDER); |
134 | - if(isset($result[0]) && isset($result[0][0])) { |
|
134 | + if (isset($result[0]) && isset($result[0][0])) { |
|
135 | 135 | $this->namespace = trim($result[1][0]); |
136 | 136 | } |
137 | 137 | |
138 | 138 | $result = array(); |
139 | 139 | preg_match_all('/(abstract|final)[\s]+(class|trait)[\s]+([\sa-z0-9\\\\_,]+){|(class|trait)[\s]+([\sa-z0-9\\\\_,]+){/six', $code, $result, PREG_PATTERN_ORDER); |
140 | 140 | |
141 | - if(!isset($result[0]) || !isset($result[0][0])) { |
|
141 | + if (!isset($result[0]) || !isset($result[0][0])) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | 145 | $indexes = array_keys($result[0]); |
146 | 146 | |
147 | - foreach($indexes as $idx) |
|
147 | + foreach ($indexes as $idx) |
|
148 | 148 | { |
149 | 149 | $keyword = $result[1][$idx]; |
150 | 150 | $declaration = $result[3][$idx]; |
151 | 151 | $type = $result[2][$idx]; |
152 | - if(empty($keyword)) { |
|
152 | + if (empty($keyword)) { |
|
153 | 153 | $type = $result[4][$idx]; |
154 | 154 | $declaration = $result[5][$idx]; |
155 | 155 | } |