@@ -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 | /** |
38 | 38 | * @var array<string,mixed> |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @see FileHelper::ERROR_SOURCE_FILE_DOES_NOT_EXIST |
87 | 87 | */ |
88 | - public function addFile(string $filePath, ?string $zipPath=null) : bool |
|
88 | + public function addFile(string $filePath, ?string $zipPath = null) : bool |
|
89 | 89 | { |
90 | 90 | $this->open(); |
91 | 91 | |
@@ -138,16 +138,16 @@ discard block |
||
138 | 138 | */ |
139 | 139 | protected function open() : void |
140 | 140 | { |
141 | - if($this->open) { |
|
141 | + if ($this->open) { |
|
142 | 142 | return; |
143 | 143 | } |
144 | 144 | |
145 | - if(!isset($this->zip)) { |
|
145 | + if (!isset($this->zip)) { |
|
146 | 146 | $this->zip = new ZipArchive(); |
147 | 147 | } |
148 | 148 | |
149 | 149 | $flag = null; |
150 | - if(!file_exists($this->file)) { |
|
150 | + if (!file_exists($this->file)) { |
|
151 | 151 | $flag = ZipArchive::CREATE; |
152 | 152 | } |
153 | 153 | |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | { |
191 | 191 | $this->fileTracker++; |
192 | 192 | |
193 | - if($this->options['WriteThreshold'] < 1) { |
|
193 | + if ($this->options['WriteThreshold'] < 1) { |
|
194 | 194 | return; |
195 | 195 | } |
196 | 196 | |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | protected function close() : void |
205 | 205 | { |
206 | - if(!$this->open) { |
|
206 | + if (!$this->open) { |
|
207 | 207 | return; |
208 | 208 | } |
209 | 209 | |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | throw new ZIPHelper_Exception( |
213 | 213 | 'Could not save ZIP file to disk', |
214 | 214 | sprintf( |
215 | - 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, ' . |
|
216 | - 'including adding files that do not exist on disk, trying to create an empty zip, ' . |
|
215 | + 'Tried saving the ZIP file [%1$s], but the write failed. This can have several causes, '. |
|
216 | + 'including adding files that do not exist on disk, trying to create an empty zip, '. |
|
217 | 217 | 'or trying to save to a directory that does not exist.', |
218 | 218 | $this->file |
219 | 219 | ), |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | { |
229 | 229 | $this->open(); |
230 | 230 | |
231 | - if($this->countFiles() < 1) |
|
231 | + if ($this->countFiles() < 1) |
|
232 | 232 | { |
233 | 233 | throw new ZIPHelper_Exception( |
234 | 234 | 'No files in the zip file', |
@@ -254,18 +254,18 @@ discard block |
||
254 | 254 | * @throws ZIPHelper_Exception |
255 | 255 | * @return string The file name that was sent (useful in case none was specified). |
256 | 256 | */ |
257 | - public function download(?string $fileName=null) : string |
|
257 | + public function download(?string $fileName = null) : string |
|
258 | 258 | { |
259 | 259 | $this->save(); |
260 | 260 | |
261 | - if(empty($fileName)) |
|
261 | + if (empty($fileName)) |
|
262 | 262 | { |
263 | 263 | $fileName = basename($this->file); |
264 | 264 | } |
265 | 265 | |
266 | 266 | header('Content-type: application/zip'); |
267 | - header('Content-Disposition: attachment; filename=' . $fileName); |
|
268 | - header('Content-length: ' . filesize($this->file)); |
|
267 | + header('Content-Disposition: attachment; filename='.$fileName); |
|
268 | + header('Content-length: '.filesize($this->file)); |
|
269 | 269 | header('Pragma: no-cache'); |
270 | 270 | header('Expires: 0'); |
271 | 271 | readfile($this->file); |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | * @throws ZIPHelper_Exception |
284 | 284 | * @see ZIPHelper::download() |
285 | 285 | */ |
286 | - public function downloadAndDelete(?string $fileName=null) : ZIPHelper |
|
286 | + public function downloadAndDelete(?string $fileName = null) : ZIPHelper |
|
287 | 287 | { |
288 | 288 | $this->download($fileName); |
289 | 289 | |
@@ -300,9 +300,9 @@ discard block |
||
300 | 300 | * @param string|NULL $outputFolder If no folder is specified, uses the target file's folder. |
301 | 301 | * @return boolean |
302 | 302 | */ |
303 | - public function extractAll(?string $outputFolder=null) : bool |
|
303 | + public function extractAll(?string $outputFolder = null) : bool |
|
304 | 304 | { |
305 | - if(empty($outputFolder)) { |
|
305 | + if (empty($outputFolder)) { |
|
306 | 306 | $outputFolder = dirname($this->file); |
307 | 307 | } |
308 | 308 |
@@ -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 |
@@ -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 | /** |
@@ -22,44 +22,44 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class FileHelper_PHPClassInfo_Class |
24 | 24 | { |
25 | - /** |
|
26 | - * @var FileHelper_PHPClassInfo |
|
27 | - */ |
|
25 | + /** |
|
26 | + * @var FileHelper_PHPClassInfo |
|
27 | + */ |
|
28 | 28 | protected $info; |
29 | 29 | |
30 | - /** |
|
31 | - * @var bool |
|
32 | - */ |
|
30 | + /** |
|
31 | + * @var bool |
|
32 | + */ |
|
33 | 33 | protected $abstract = false; |
34 | 34 | |
35 | - /** |
|
36 | - * @var bool |
|
37 | - */ |
|
35 | + /** |
|
36 | + * @var bool |
|
37 | + */ |
|
38 | 38 | protected $final = false; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $extends = ''; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[] |
|
47 | + */ |
|
48 | 48 | protected $implements = array(); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $name; |
54 | 54 | |
55 | - /** |
|
56 | - * @var string |
|
57 | - */ |
|
55 | + /** |
|
56 | + * @var string |
|
57 | + */ |
|
58 | 58 | protected $declaration; |
59 | 59 | |
60 | - /** |
|
61 | - * @var string |
|
62 | - */ |
|
60 | + /** |
|
61 | + * @var string |
|
62 | + */ |
|
63 | 63 | protected $keyword; |
64 | 64 | |
65 | 65 | /** |
@@ -68,10 +68,10 @@ discard block |
||
68 | 68 | private $type; |
69 | 69 | |
70 | 70 | /** |
71 | - * @param FileHelper_PHPClassInfo $info The class info instance. |
|
72 | - * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
73 | - * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
74 | - */ |
|
71 | + * @param FileHelper_PHPClassInfo $info The class info instance. |
|
72 | + * @param string $declaration The full class declaration, e.g. "class SomeName extends SomeOtherClass". |
|
73 | + * @param string $keyword The class keyword, if any, i.e. "abstract" or "final". |
|
74 | + */ |
|
75 | 75 | public function __construct(FileHelper_PHPClassInfo $info, string $declaration, string $keyword, string $type) |
76 | 76 | { |
77 | 77 | $this->info = $info; |
@@ -82,31 +82,31 @@ discard block |
||
82 | 82 | $this->analyzeCode(); |
83 | 83 | } |
84 | 84 | |
85 | - /** |
|
86 | - * Check if this class is a subclass of the specified |
|
87 | - * class name. |
|
88 | - * |
|
89 | - * @param string $className |
|
90 | - * @return bool |
|
91 | - */ |
|
85 | + /** |
|
86 | + * Check if this class is a subclass of the specified |
|
87 | + * class name. |
|
88 | + * |
|
89 | + * @param string $className |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | 92 | public function isSublassOf(string $className) : bool |
93 | 93 | { |
94 | 94 | return is_subclass_of($this->getNameNS(), $className); |
95 | 95 | } |
96 | 96 | |
97 | - /** |
|
98 | - * The class name without namespace. |
|
99 | - * @return string |
|
100 | - */ |
|
97 | + /** |
|
98 | + * The class name without namespace. |
|
99 | + * @return string |
|
100 | + */ |
|
101 | 101 | public function getName() : string |
102 | 102 | { |
103 | 103 | return $this->name; |
104 | 104 | } |
105 | 105 | |
106 | - /** |
|
107 | - * The absolute class name with namespace (if any). |
|
108 | - * @return string |
|
109 | - */ |
|
106 | + /** |
|
107 | + * The absolute class name with namespace (if any). |
|
108 | + * @return string |
|
109 | + */ |
|
110 | 110 | public function getNameNS() : string |
111 | 111 | { |
112 | 112 | $name = $this->getName(); |
@@ -118,48 +118,48 @@ discard block |
||
118 | 118 | return $name; |
119 | 119 | } |
120 | 120 | |
121 | - /** |
|
122 | - * Whether it is an abstract class. |
|
123 | - * @return bool |
|
124 | - */ |
|
121 | + /** |
|
122 | + * Whether it is an abstract class. |
|
123 | + * @return bool |
|
124 | + */ |
|
125 | 125 | public function isAbstract() : bool |
126 | 126 | { |
127 | 127 | return $this->abstract; |
128 | 128 | } |
129 | 129 | |
130 | - /** |
|
131 | - * Whether it is a final class. |
|
132 | - * @return bool |
|
133 | - */ |
|
130 | + /** |
|
131 | + * Whether it is a final class. |
|
132 | + * @return bool |
|
133 | + */ |
|
134 | 134 | public function isFinal() : bool |
135 | 135 | { |
136 | 136 | return $this->final; |
137 | 137 | } |
138 | 138 | |
139 | - /** |
|
140 | - * The name of the class that this class extends (with namespace, if specified). |
|
141 | - * @return string |
|
142 | - */ |
|
139 | + /** |
|
140 | + * The name of the class that this class extends (with namespace, if specified). |
|
141 | + * @return string |
|
142 | + */ |
|
143 | 143 | public function getExtends() : string |
144 | 144 | { |
145 | 145 | return $this->extends; |
146 | 146 | } |
147 | 147 | |
148 | - /** |
|
149 | - * A list of interfaces the class implements, if any. |
|
150 | - * @return string[] |
|
151 | - */ |
|
148 | + /** |
|
149 | + * A list of interfaces the class implements, if any. |
|
150 | + * @return string[] |
|
151 | + */ |
|
152 | 152 | public function getImplements() : array |
153 | 153 | { |
154 | 154 | return $this->implements; |
155 | 155 | } |
156 | 156 | |
157 | - /** |
|
158 | - * The class declaration string, with normalized spaces and sorted interface names. |
|
159 | - * NOTE: does not include the keyword "abstract" or "final". |
|
160 | - * |
|
161 | - * @return string |
|
162 | - */ |
|
157 | + /** |
|
158 | + * The class declaration string, with normalized spaces and sorted interface names. |
|
159 | + * NOTE: does not include the keyword "abstract" or "final". |
|
160 | + * |
|
161 | + * @return string |
|
162 | + */ |
|
163 | 163 | public function getDeclaration() : string |
164 | 164 | { |
165 | 165 | $parts = array(); |
@@ -179,10 +179,10 @@ discard block |
||
179 | 179 | return implode(' ', $parts); |
180 | 180 | } |
181 | 181 | |
182 | - /** |
|
183 | - * The keyword before "class", e.g. "abstract". |
|
184 | - * @return string |
|
185 | - */ |
|
182 | + /** |
|
183 | + * The keyword before "class", e.g. "abstract". |
|
184 | + * @return string |
|
185 | + */ |
|
186 | 186 | public function getKeyword() : string |
187 | 187 | { |
188 | 188 | return $this->keyword; |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | { |
112 | 112 | $name = $this->getName(); |
113 | 113 | |
114 | - if($this->info->hasNamespace()) { |
|
114 | + if ($this->info->hasNamespace()) { |
|
115 | 115 | $name = $this->info->getNamespace().'\\'.$this->name; |
116 | 116 | } |
117 | 117 | |
@@ -166,12 +166,12 @@ discard block |
||
166 | 166 | $parts[] = $this->type; |
167 | 167 | $parts[] = $this->getName(); |
168 | 168 | |
169 | - if(!empty($this->extends)) { |
|
169 | + if (!empty($this->extends)) { |
|
170 | 170 | $parts[] = 'extends'; |
171 | 171 | $parts[] = $this->extends; |
172 | 172 | } |
173 | 173 | |
174 | - if(!empty($this->implements)) { |
|
174 | + if (!empty($this->implements)) { |
|
175 | 175 | $parts[] = 'implements'; |
176 | 176 | $parts[] = implode(', ', $this->implements); |
177 | 177 | } |
@@ -195,9 +195,9 @@ discard block |
||
195 | 195 | |
196 | 196 | protected function analyzeCode() : void |
197 | 197 | { |
198 | - if($this->keyword === 'abstract') { |
|
198 | + if ($this->keyword === 'abstract') { |
|
199 | 199 | $this->abstract = true; |
200 | - } else if($this->keyword === 'final') { |
|
200 | + } else if ($this->keyword === 'final') { |
|
201 | 201 | $this->final = true; |
202 | 202 | } |
203 | 203 | |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | |
215 | 215 | $tokenName = 'none'; |
216 | 216 | |
217 | - foreach($parts as $part) |
|
217 | + foreach ($parts as $part) |
|
218 | 218 | { |
219 | 219 | $part = str_replace(',', '', $part); |
220 | 220 | $part = trim($part); |
221 | - if(empty($part)) { |
|
221 | + if (empty($part)) { |
|
222 | 222 | continue; |
223 | 223 | } |
224 | 224 | |
225 | 225 | $name = strtolower($part); |
226 | - if($name === 'extends' || $name === 'implements') { |
|
226 | + if ($name === 'extends' || $name === 'implements') { |
|
227 | 227 | $tokenName = $name; |
228 | 228 | continue; |
229 | 229 | } |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | |
234 | 234 | $this->implements = $tokens['implements']; |
235 | 235 | |
236 | - if(!empty($this->implements)) { |
|
236 | + if (!empty($this->implements)) { |
|
237 | 237 | usort($this->implements, function(string $a, string $b) { |
238 | 238 | return strnatcasecmp($a, $b); |
239 | 239 | }); |
240 | 240 | } |
241 | 241 | |
242 | - if(!empty($tokens['extends'])) { |
|
242 | + if (!empty($tokens['extends'])) { |
|
243 | 243 | $this->extends = $tokens['extends'][0]; |
244 | 244 | } |
245 | 245 | } |
@@ -500,8 +500,7 @@ |
||
500 | 500 | try |
501 | 501 | { |
502 | 502 | return $content(); |
503 | - } |
|
504 | - catch (Exception $e) |
|
503 | + } catch (Exception $e) |
|
505 | 504 | { |
506 | 505 | throw new StringBuilder_Exception( |
507 | 506 | 'The callable has thrown an error.', |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | { |
38 | 38 | public const ERROR_CALLABLE_THREW_ERROR = 99601; |
39 | 39 | |
40 | - /** |
|
41 | - * @var string |
|
42 | - */ |
|
40 | + /** |
|
41 | + * @var string |
|
42 | + */ |
|
43 | 43 | protected $separator = ' '; |
44 | 44 | |
45 | - /** |
|
46 | - * @var string[] |
|
47 | - */ |
|
45 | + /** |
|
46 | + * @var string[] |
|
47 | + */ |
|
48 | 48 | protected $strings = array(); |
49 | 49 | |
50 | - /** |
|
51 | - * @var string |
|
52 | - */ |
|
50 | + /** |
|
51 | + * @var string |
|
52 | + */ |
|
53 | 53 | protected $noSeparator = '§!§'; |
54 | 54 | |
55 | 55 | public function __construct() |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | return $this; |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * Adds a subject as a string. Is ignored if empty. |
|
68 | - * |
|
69 | - * @param string|number|Interface_Stringable|NULL $string |
|
70 | - * @return $this |
|
71 | - */ |
|
66 | + /** |
|
67 | + * Adds a subject as a string. Is ignored if empty. |
|
68 | + * |
|
69 | + * @param string|number|Interface_Stringable|NULL $string |
|
70 | + * @return $this |
|
71 | + */ |
|
72 | 72 | public function add($string) : StringBuilder |
73 | 73 | { |
74 | 74 | $string = (string)$string; |
@@ -81,12 +81,12 @@ discard block |
||
81 | 81 | return $this; |
82 | 82 | } |
83 | 83 | |
84 | - /** |
|
85 | - * Adds a string without appending an automatic space. |
|
86 | - * |
|
87 | - * @param string|number|Interface_Stringable|NULL $string |
|
88 | - * @return $this |
|
89 | - */ |
|
84 | + /** |
|
85 | + * Adds a string without appending an automatic space. |
|
86 | + * |
|
87 | + * @param string|number|Interface_Stringable|NULL $string |
|
88 | + * @return $this |
|
89 | + */ |
|
90 | 90 | public function nospace($string) : StringBuilder |
91 | 91 | { |
92 | 92 | $flattened = (string)$string; |
@@ -99,46 +99,46 @@ discard block |
||
99 | 99 | return $this; |
100 | 100 | } |
101 | 101 | |
102 | - /** |
|
103 | - * Adds raw HTML code. Does not add an automatic space. |
|
104 | - * |
|
105 | - * @param string|number|Interface_Stringable $html |
|
106 | - * @return $this |
|
107 | - */ |
|
102 | + /** |
|
103 | + * Adds raw HTML code. Does not add an automatic space. |
|
104 | + * |
|
105 | + * @param string|number|Interface_Stringable $html |
|
106 | + * @return $this |
|
107 | + */ |
|
108 | 108 | public function html($html) : StringBuilder |
109 | 109 | { |
110 | 110 | return $this->nospace($html); |
111 | 111 | } |
112 | 112 | |
113 | - /** |
|
114 | - * Adds an unordered list with the specified items. |
|
115 | - * |
|
116 | - * @param array<int,string|number|Interface_Stringable> $items |
|
117 | - * @return $this |
|
118 | - */ |
|
113 | + /** |
|
114 | + * Adds an unordered list with the specified items. |
|
115 | + * |
|
116 | + * @param array<int,string|number|Interface_Stringable> $items |
|
117 | + * @return $this |
|
118 | + */ |
|
119 | 119 | public function ul(array $items) : StringBuilder |
120 | 120 | { |
121 | 121 | return $this->list('ul', $items); |
122 | 122 | } |
123 | 123 | |
124 | - /** |
|
125 | - * Adds an ordered list with the specified items. |
|
126 | - * |
|
127 | - * @param array<int,string|number|Interface_Stringable> $items |
|
128 | - * @return $this |
|
129 | - */ |
|
124 | + /** |
|
125 | + * Adds an ordered list with the specified items. |
|
126 | + * |
|
127 | + * @param array<int,string|number|Interface_Stringable> $items |
|
128 | + * @return $this |
|
129 | + */ |
|
130 | 130 | public function ol(array $items) : StringBuilder |
131 | 131 | { |
132 | 132 | return $this->list('ol', $items); |
133 | 133 | } |
134 | 134 | |
135 | - /** |
|
136 | - * Creates a list tag with the items list. |
|
137 | - * |
|
138 | - * @param string $type The list type, `ol` or `ul`. |
|
139 | - * @param array<int,string|number|Interface_Stringable> $items |
|
140 | - * @return $this |
|
141 | - */ |
|
135 | + /** |
|
136 | + * Creates a list tag with the items list. |
|
137 | + * |
|
138 | + * @param string $type The list type, `ol` or `ul`. |
|
139 | + * @param array<int,string|number|Interface_Stringable> $items |
|
140 | + * @return $this |
|
141 | + */ |
|
142 | 142 | protected function list(string $type, array $items) : StringBuilder |
143 | 143 | { |
144 | 144 | return $this->html(sprintf( |
@@ -148,13 +148,13 @@ discard block |
||
148 | 148 | )); |
149 | 149 | } |
150 | 150 | |
151 | - /** |
|
152 | - * Add a translated string. |
|
153 | - * |
|
154 | - * @param string $format The native string to translate. |
|
155 | - * @param array<int,mixed> $arguments The variables to inject into the translated string, if any. |
|
156 | - * @return $this |
|
157 | - */ |
|
151 | + /** |
|
152 | + * Add a translated string. |
|
153 | + * |
|
154 | + * @param string $format The native string to translate. |
|
155 | + * @param array<int,mixed> $arguments The variables to inject into the translated string, if any. |
|
156 | + * @return $this |
|
157 | + */ |
|
158 | 158 | public function t(string $format, ...$arguments) : StringBuilder |
159 | 159 | { |
160 | 160 | if(!class_exists('\AppLocalize\Localization')) |
@@ -207,36 +207,36 @@ discard block |
||
207 | 207 | return $this->add(ConvertHelper::duration2string($since)); |
208 | 208 | } |
209 | 209 | |
210 | - /** |
|
211 | - * Adds HTML double quotes around the string. |
|
212 | - * |
|
213 | - * @param string|number|Interface_Stringable $string |
|
214 | - * @return $this |
|
215 | - */ |
|
210 | + /** |
|
211 | + * Adds HTML double quotes around the string. |
|
212 | + * |
|
213 | + * @param string|number|Interface_Stringable $string |
|
214 | + * @return $this |
|
215 | + */ |
|
216 | 216 | public function quote($string) : StringBuilder |
217 | 217 | { |
218 | 218 | return $this->sf('"%s"', (string)$string); |
219 | 219 | } |
220 | 220 | |
221 | - /** |
|
222 | - * Adds a text that is meant as a reference to a UI element, |
|
223 | - * like a menu item, button, etc. |
|
224 | - * |
|
225 | - * @param string|number|Interface_Stringable $string |
|
226 | - * @return $this |
|
227 | - */ |
|
221 | + /** |
|
222 | + * Adds a text that is meant as a reference to a UI element, |
|
223 | + * like a menu item, button, etc. |
|
224 | + * |
|
225 | + * @param string|number|Interface_Stringable $string |
|
226 | + * @return $this |
|
227 | + */ |
|
228 | 228 | public function reference($string) : StringBuilder |
229 | 229 | { |
230 | 230 | return $this->sf('"%s"', $string); |
231 | 231 | } |
232 | 232 | |
233 | - /** |
|
234 | - * Add a string using the `sprintf` method. |
|
235 | - * |
|
236 | - * @param string $format The format string |
|
237 | - * @param string|number|Interface_Stringable ...$arguments The variables to inject |
|
238 | - * @return $this |
|
239 | - */ |
|
233 | + /** |
|
234 | + * Add a string using the `sprintf` method. |
|
235 | + * |
|
236 | + * @param string $format The format string |
|
237 | + * @param string|number|Interface_Stringable ...$arguments The variables to inject |
|
238 | + * @return $this |
|
239 | + */ |
|
240 | 240 | public function sf(string $format, ...$arguments) : StringBuilder |
241 | 241 | { |
242 | 242 | array_unshift($arguments, $format); |
@@ -244,12 +244,12 @@ discard block |
||
244 | 244 | return $this->add(sprintf(...$arguments)); |
245 | 245 | } |
246 | 246 | |
247 | - /** |
|
248 | - * Adds a bold string. |
|
249 | - * |
|
250 | - * @param string|number|Interface_Stringable $string |
|
251 | - * @return $this |
|
252 | - */ |
|
247 | + /** |
|
248 | + * Adds a bold string. |
|
249 | + * |
|
250 | + * @param string|number|Interface_Stringable $string |
|
251 | + * @return $this |
|
252 | + */ |
|
253 | 253 | public function bold($string) : StringBuilder |
254 | 254 | { |
255 | 255 | return $this->sf( |
@@ -258,15 +258,15 @@ discard block |
||
258 | 258 | ); |
259 | 259 | } |
260 | 260 | |
261 | - /** |
|
262 | - * Adds an HTML `<br>` tag. |
|
263 | - * |
|
264 | - * Note: for adding a newline character instead, |
|
265 | - * use {@see StringBuilder::eol()}. |
|
266 | - * |
|
267 | - * @return $this |
|
268 | - * @see StringBuilder::eol() |
|
269 | - */ |
|
261 | + /** |
|
262 | + * Adds an HTML `<br>` tag. |
|
263 | + * |
|
264 | + * Note: for adding a newline character instead, |
|
265 | + * use {@see StringBuilder::eol()}. |
|
266 | + * |
|
267 | + * @return $this |
|
268 | + * @see StringBuilder::eol() |
|
269 | + */ |
|
270 | 270 | public function nl() : StringBuilder |
271 | 271 | { |
272 | 272 | return $this->html('<br>'); |
@@ -283,42 +283,42 @@ discard block |
||
283 | 283 | return $this->nospace(PHP_EOL); |
284 | 284 | } |
285 | 285 | |
286 | - /** |
|
287 | - * Adds the current time, in the format <code>H:i:s</code>. |
|
288 | - * |
|
289 | - * @return $this |
|
290 | - */ |
|
286 | + /** |
|
287 | + * Adds the current time, in the format <code>H:i:s</code>. |
|
288 | + * |
|
289 | + * @return $this |
|
290 | + */ |
|
291 | 291 | public function time() : StringBuilder |
292 | 292 | { |
293 | 293 | return $this->add(date('H:i:s')); |
294 | 294 | } |
295 | 295 | |
296 | - /** |
|
297 | - * Adds the "Note:" text. |
|
298 | - * |
|
299 | - * @return $this |
|
300 | - */ |
|
296 | + /** |
|
297 | + * Adds the "Note:" text. |
|
298 | + * |
|
299 | + * @return $this |
|
300 | + */ |
|
301 | 301 | public function note() : StringBuilder |
302 | 302 | { |
303 | 303 | return $this->t('Note:'); |
304 | 304 | } |
305 | 305 | |
306 | - /** |
|
307 | - * Like {@see StringBuilder::note()}, but as bold text. |
|
308 | - * |
|
309 | - * @return $this |
|
310 | - */ |
|
306 | + /** |
|
307 | + * Like {@see StringBuilder::note()}, but as bold text. |
|
308 | + * |
|
309 | + * @return $this |
|
310 | + */ |
|
311 | 311 | public function noteBold() : StringBuilder |
312 | 312 | { |
313 | 313 | return $this->bold(sb()->note()); |
314 | 314 | } |
315 | 315 | |
316 | - /** |
|
317 | - * Adds the "Hint:" text. |
|
318 | - * |
|
319 | - * @return $this |
|
320 | - * @see StringBuilder::hintBold() |
|
321 | - */ |
|
316 | + /** |
|
317 | + * Adds the "Hint:" text. |
|
318 | + * |
|
319 | + * @return $this |
|
320 | + * @see StringBuilder::hintBold() |
|
321 | + */ |
|
322 | 322 | public function hint() : StringBuilder |
323 | 323 | { |
324 | 324 | return $this->t('Hint:'); |
@@ -334,12 +334,12 @@ discard block |
||
334 | 334 | return $this->bold(sb()->hint()); |
335 | 335 | } |
336 | 336 | |
337 | - /** |
|
338 | - * Adds two linebreaks. |
|
339 | - * |
|
340 | - * @param StringBuilder_Interface|string|NULL $content |
|
341 | - * @return $this |
|
342 | - */ |
|
337 | + /** |
|
338 | + * Adds two linebreaks. |
|
339 | + * |
|
340 | + * @param StringBuilder_Interface|string|NULL $content |
|
341 | + * @return $this |
|
342 | + */ |
|
343 | 343 | public function para($content=null) : StringBuilder |
344 | 344 | { |
345 | 345 | if($content !== null) { |
@@ -391,12 +391,12 @@ discard block |
||
391 | 391 | return $this->html(HTMLTag::create('a')->renderClose()); |
392 | 392 | } |
393 | 393 | |
394 | - /** |
|
395 | - * Wraps the string in a `code` tag. |
|
396 | - * |
|
397 | - * @param string|number|Interface_Stringable $string |
|
398 | - * @return $this |
|
399 | - */ |
|
394 | + /** |
|
395 | + * Wraps the string in a `code` tag. |
|
396 | + * |
|
397 | + * @param string|number|Interface_Stringable $string |
|
398 | + * @return $this |
|
399 | + */ |
|
400 | 400 | public function code($string) : StringBuilder |
401 | 401 | { |
402 | 402 | return $this->sf( |
@@ -405,24 +405,24 @@ discard block |
||
405 | 405 | ); |
406 | 406 | } |
407 | 407 | |
408 | - /** |
|
409 | - * Wraps the string in a `pre` tag. |
|
410 | - * |
|
411 | - * @param string|number|Interface_Stringable $string |
|
412 | - * @return $this |
|
413 | - */ |
|
408 | + /** |
|
409 | + * Wraps the string in a `pre` tag. |
|
410 | + * |
|
411 | + * @param string|number|Interface_Stringable $string |
|
412 | + * @return $this |
|
413 | + */ |
|
414 | 414 | public function pre($string) : StringBuilder |
415 | 415 | { |
416 | 416 | return $this->sf('<pre>%s</pre>', (string)$string); |
417 | 417 | } |
418 | 418 | |
419 | - /** |
|
420 | - * Wraps the text in a `span` tag with the specified classes. |
|
421 | - * |
|
422 | - * @param string|number|Interface_Stringable $string |
|
423 | - * @param string|string[] $classes |
|
424 | - * @return $this |
|
425 | - */ |
|
419 | + /** |
|
420 | + * Wraps the text in a `span` tag with the specified classes. |
|
421 | + * |
|
422 | + * @param string|number|Interface_Stringable $string |
|
423 | + * @param string|string[] $classes |
|
424 | + * @return $this |
|
425 | + */ |
|
426 | 426 | public function spanned($string, $classes) : StringBuilder |
427 | 427 | { |
428 | 428 | if(!is_array($classes)) |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | { |
74 | 74 | $string = (string)$string; |
75 | 75 | |
76 | - if(!empty($string)) |
|
76 | + if (!empty($string)) |
|
77 | 77 | { |
78 | 78 | $this->strings[] = $string; |
79 | 79 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | { |
92 | 92 | $flattened = (string)$string; |
93 | 93 | |
94 | - if($flattened !== "") |
|
94 | + if ($flattened !== "") |
|
95 | 95 | { |
96 | 96 | $this->add($this->noSeparator.$flattened); |
97 | 97 | } |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | */ |
158 | 158 | public function t(string $format, ...$arguments) : StringBuilder |
159 | 159 | { |
160 | - if(!class_exists('\AppLocalize\Localization')) |
|
160 | + if (!class_exists('\AppLocalize\Localization')) |
|
161 | 161 | { |
162 | 162 | array_unshift($arguments, $format); |
163 | 163 | return $this->sf(...$arguments); |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | { |
183 | 183 | unset($context); // Only used by the localization parser. |
184 | 184 | |
185 | - if(!class_exists('\AppLocalize\Localization')) |
|
185 | + if (!class_exists('\AppLocalize\Localization')) |
|
186 | 186 | { |
187 | 187 | array_unshift($arguments, $format); |
188 | 188 | return $this->sf(...$arguments); |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | * @param StringBuilder_Interface|string|NULL $content |
341 | 341 | * @return $this |
342 | 342 | */ |
343 | - public function para($content=null) : StringBuilder |
|
343 | + public function para($content = null) : StringBuilder |
|
344 | 344 | { |
345 | - if($content !== null) { |
|
345 | + if ($content !== null) { |
|
346 | 346 | return $this->html('<p>')->nospace($content)->html('</p>'); |
347 | 347 | } |
348 | 348 | |
@@ -358,21 +358,21 @@ discard block |
||
358 | 358 | * @param AttributeCollection|null $attributes |
359 | 359 | * @return $this |
360 | 360 | */ |
361 | - public function link(string $label, string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : StringBuilder |
|
361 | + public function link(string $label, string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : StringBuilder |
|
362 | 362 | { |
363 | 363 | return $this->add($this->createLink($label, $url, $newTab, $attributes)); |
364 | 364 | } |
365 | 365 | |
366 | - private function createLink(string $label, string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : HTMLTag |
|
366 | + private function createLink(string $label, string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : HTMLTag |
|
367 | 367 | { |
368 | - if($attributes === null) |
|
368 | + if ($attributes === null) |
|
369 | 369 | { |
370 | 370 | $attributes = AttributeCollection::create(); |
371 | 371 | } |
372 | 372 | |
373 | 373 | $attributes->href($url); |
374 | 374 | |
375 | - if($newTab) |
|
375 | + if ($newTab) |
|
376 | 376 | { |
377 | 377 | $attributes->target(); |
378 | 378 | } |
@@ -381,7 +381,7 @@ discard block |
||
381 | 381 | ->addText($label); |
382 | 382 | } |
383 | 383 | |
384 | - public function linkOpen(string $url, bool $newTab=false, ?AttributeCollection $attributes=null) : StringBuilder |
|
384 | + public function linkOpen(string $url, bool $newTab = false, ?AttributeCollection $attributes = null) : StringBuilder |
|
385 | 385 | { |
386 | 386 | return $this->html($this->createLink('', $url, $newTab, $attributes)->renderOpen()); |
387 | 387 | } |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | */ |
426 | 426 | public function spanned($string, $classes) : StringBuilder |
427 | 427 | { |
428 | - if(!is_array($classes)) |
|
428 | + if (!is_array($classes)) |
|
429 | 429 | { |
430 | 430 | $classes = array((string)$classes); |
431 | 431 | } |
@@ -443,7 +443,7 @@ discard block |
||
443 | 443 | * @return $this |
444 | 444 | * @throws ConvertHelper_Exception |
445 | 445 | */ |
446 | - public function bool($value, bool $yesNo=false) : StringBuilder |
|
446 | + public function bool($value, bool $yesNo = false) : StringBuilder |
|
447 | 447 | { |
448 | 448 | return $this->add(ConvertHelper::bool2string($value, $yesNo)); |
449 | 449 | } |
@@ -462,7 +462,7 @@ discard block |
||
462 | 462 | */ |
463 | 463 | public function ifTrue(bool $condition, $content) : StringBuilder |
464 | 464 | { |
465 | - if($condition === true) |
|
465 | + if ($condition === true) |
|
466 | 466 | { |
467 | 467 | $this->add($this->renderContent($content)); |
468 | 468 | } |
@@ -484,7 +484,7 @@ discard block |
||
484 | 484 | */ |
485 | 485 | public function ifFalse(bool $condition, $string) : StringBuilder |
486 | 486 | { |
487 | - if($condition === false) |
|
487 | + if ($condition === false) |
|
488 | 488 | { |
489 | 489 | $this->add($this->renderContent($string)); |
490 | 490 | } |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | */ |
569 | 569 | public function ifOr(bool $condition, $ifTrue, $ifFalse) : StringBuilder |
570 | 570 | { |
571 | - if($condition === true) |
|
571 | + if ($condition === true) |
|
572 | 572 | { |
573 | 573 | return $this->add($this->renderContent($ifTrue)); |
574 | 574 | } |
@@ -24,14 +24,14 @@ discard block |
||
24 | 24 | |
25 | 25 | $attributes = $this->compileAttributes(); |
26 | 26 | |
27 | - if(empty($attributes)) |
|
27 | + if (empty($attributes)) |
|
28 | 28 | { |
29 | 29 | return ''; |
30 | 30 | } |
31 | 31 | |
32 | - foreach($attributes as $name => $value) |
|
32 | + foreach ($attributes as $name => $value) |
|
33 | 33 | { |
34 | - if($value === '') |
|
34 | + if ($value === '') |
|
35 | 35 | { |
36 | 36 | continue; |
37 | 37 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | { |
54 | 54 | $attributes = $this->collection->getRawAttributes(); |
55 | 55 | |
56 | - if($this->collection->hasClasses()) |
|
56 | + if ($this->collection->hasClasses()) |
|
57 | 57 | { |
58 | 58 | $attributes['class'] = $this->collection->classesToString(); |
59 | 59 | } |
60 | 60 | |
61 | - if($this->collection->hasStyles()) |
|
61 | + if ($this->collection->hasStyles()) |
|
62 | 62 | { |
63 | 63 | $attributes['style'] = $this->collection->getStyles() |
64 | 64 | ->configureForInline() |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | |
71 | 71 | private function renderAttribute(string $name, string $value) : string |
72 | 72 | { |
73 | - if($name === $value) |
|
73 | + if ($name === $value) |
|
74 | 74 | { |
75 | 75 | return $name; |
76 | 76 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | |
27 | 27 | public function render() : string |
28 | 28 | { |
29 | - if($this->collection->hasStyles()) |
|
29 | + if ($this->collection->hasStyles()) |
|
30 | 30 | { |
31 | 31 | return implode( |
32 | 32 | $this->resolveSeparator(), |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | private function resolveSuffix() : string |
41 | 41 | { |
42 | - if($this->options->isTrailingSemicolonEnabled()) |
|
42 | + if ($this->options->isTrailingSemicolonEnabled()) |
|
43 | 43 | { |
44 | 44 | return ';'; |
45 | 45 | } |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | |
50 | 50 | private function resolveSeparator() : string |
51 | 51 | { |
52 | - if($this->options->isNewlineEnabled()) |
|
52 | + if ($this->options->isNewlineEnabled()) |
|
53 | 53 | { |
54 | 54 | return ';'.PHP_EOL; |
55 | 55 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | { |
62 | 62 | $indentLevel = $this->options->getIndentLevel(); |
63 | 63 | |
64 | - if($indentLevel > 0) |
|
64 | + if ($indentLevel > 0) |
|
65 | 65 | { |
66 | 66 | return str_repeat($this->options->getIndentChar(), $indentLevel); |
67 | 67 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | |
72 | 72 | private function resolveValueSpace() : string |
73 | 73 | { |
74 | - if($this->options->isSpaceBeforeValueEnabled()) |
|
74 | + if ($this->options->isSpaceBeforeValueEnabled()) |
|
75 | 75 | { |
76 | 76 | return ' '; |
77 | 77 | } |
@@ -86,12 +86,12 @@ discard block |
||
86 | 86 | $indent = $this->resolveIndent(); |
87 | 87 | $valueSpace = $this->resolveValueSpace(); |
88 | 88 | |
89 | - if($this->options->isSortingEnabled()) |
|
89 | + if ($this->options->isSortingEnabled()) |
|
90 | 90 | { |
91 | 91 | ksort($styles); |
92 | 92 | } |
93 | 93 | |
94 | - foreach($styles as $name => $value) |
|
94 | + foreach ($styles as $name => $value) |
|
95 | 95 | { |
96 | 96 | $lines[] = sprintf( |
97 | 97 | '%s%s:%s%s', |