Passed
Push — master ( 289f9d...bae7fb )
by Sebastian
04:42
created
src/ConvertHelper/Date.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
      * @param bool $short
44 44
      * @return string|NULL
45 45
      */
46
-    public static function toDayName(DateTime $date, bool $short=false) : ?string
46
+    public static function toDayName(DateTime $date, bool $short = false) : ?string
47 47
     {
48 48
         $day = $date->format('l');
49 49
         $invariant = self::getDayNamesInvariant();
50 50
 
51 51
         $idx = array_search($day, $invariant);
52
-        if($idx !== false) {
52
+        if ($idx !== false) {
53 53
             $localized = self::getDayNames($short);
54 54
             return $localized[$idx];
55 55
         }
@@ -72,11 +72,11 @@  discard block
 block discarded – undo
72 72
      * @param bool $short
73 73
      * @return string[]
74 74
      */
75
-    public static function getDayNames(bool $short=false) : array
75
+    public static function getDayNames(bool $short = false) : array
76 76
     {
77 77
         self::initDays();
78 78
 
79
-        if($short) {
79
+        if ($short) {
80 80
             return self::$daysShort;
81 81
         }
82 82
 
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
     public static function toListLabel(DateTime $date, bool $includeTime = false, bool $shortMonth = false) : string
103 103
     {
104 104
         $today = new DateTime();
105
-        if($date->format('d.m.Y') === $today->format('d.m.Y'))
105
+        if ($date->format('d.m.Y') === $today->format('d.m.Y'))
106 106
         {
107 107
             $label = t('Today');
108 108
         }
109 109
         else
110 110
         {
111
-            $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
111
+            $label = $date->format('d').'. '.self::month2string((int)$date->format('m'), $shortMonth).' ';
112 112
 
113 113
             if ($date->format('Y') != date('Y'))
114 114
             {
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
 
214 214
     private static function initDays() : void
215 215
     {
216
-        if(!empty(self::$daysShort))
216
+        if (!empty(self::$daysShort))
217 217
         {
218 218
             return;
219 219
         }
Please login to merge, or discard this patch.
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,8 +105,7 @@
 block discarded – undo
105 105
         if($date->format('d.m.Y') === $today->format('d.m.Y'))
106 106
         {
107 107
             $label = t('Today');
108
-        }
109
-        else
108
+        } else
110 109
         {
111 110
             $label = $date->format('d') . '. ' . self::month2string((int)$date->format('m'), $shortMonth) . ' ';
112 111
 
Please login to merge, or discard this patch.
src/ConvertHelper/Array.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,9 +15,9 @@  discard block
 block discarded – undo
15 15
      */
16 16
     public static function removeKeys(array &$sourceArray, array $keys) : void
17 17
     {
18
-        foreach($keys as $key)
18
+        foreach ($keys as $key)
19 19
         {
20
-            if(array_key_exists($key, $sourceArray)) {
20
+            if (array_key_exists($key, $sourceArray)) {
21 21
                 unset($sourceArray[$key]);
22 22
             }
23 23
         }
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
      * @param bool $keepKeys Whether to maintain index association
32 32
      * @return array<number|string,mixed>
33 33
      */
34
-    public static function removeValues(array $sourceArray, array $values, bool $keepKeys=false) : array
34
+    public static function removeValues(array $sourceArray, array $values, bool $keepKeys = false) : array
35 35
     {
36 36
         $result = array();
37 37
         $values = array_values($values);
38 38
 
39
-        foreach($sourceArray as $key => $value)
39
+        foreach ($sourceArray as $key => $value)
40 40
         {
41
-            if(in_array($value, $values, true)) {
41
+            if (in_array($value, $values, true)) {
42 42
                 continue;
43 43
             }
44 44
 
45
-            if($keepKeys) {
45
+            if ($keepKeys) {
46 46
                 $result[$key] = $value;
47 47
                 continue;
48 48
             }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
     public static function toStyleString(array $subject) : string
76 76
     {
77 77
         $tokens = array();
78
-        foreach($subject as $name => $value) {
78
+        foreach ($subject as $name => $value) {
79 79
             $tokens[] = $name.':'.strval($value);
80 80
         }
81 81
 
@@ -104,18 +104,18 @@  discard block
 block discarded – undo
104 104
     public static function toAttributeString(array $array) : string
105 105
     {
106 106
         $tokens = array();
107
-        foreach($array as $attr => $value)
107
+        foreach ($array as $attr => $value)
108 108
         {
109 109
             $value = strval($value);
110 110
 
111
-            if($value === '') {
111
+            if ($value === '') {
112 112
                 continue;
113 113
             }
114 114
 
115 115
             $tokens[] = $attr.'="'.htmlspecialchars($value, ENT_QUOTES, 'UTF-8').'"';
116 116
         }
117 117
 
118
-        if(empty($tokens)) {
118
+        if (empty($tokens)) {
119 119
             return '';
120 120
         }
121 121
 
@@ -136,17 +136,17 @@  discard block
 block discarded – undo
136 136
      */
137 137
     public static function implodeWithAnd(array $list, string $sep = ', ', string $conjunction = '') : string
138 138
     {
139
-        if(empty($list)) {
139
+        if (empty($list)) {
140 140
             return '';
141 141
         }
142 142
 
143
-        if(empty($conjunction)) {
143
+        if (empty($conjunction)) {
144 144
             $conjunction = ' '.t('and').' ';
145 145
         }
146 146
 
147 147
         $last = array_pop($list);
148
-        if($list) {
149
-            return implode($sep, $list) . $conjunction . $last;
148
+        if ($list) {
149
+            return implode($sep, $list).$conjunction.$last;
150 150
         }
151 151
 
152 152
         return $last;
Please login to merge, or discard this patch.
src/StringBuilder.php 2 patches
Indentation   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
  */
34 34
 class StringBuilder implements StringBuilder_Interface
35 35
 {
36
-   /**
37
-    * @var string
38
-    */
36
+    /**
37
+     * @var string
38
+     */
39 39
     protected $separator = ' ';
40 40
 
41
-   /**
42
-    * @var string[]
43
-    */
41
+    /**
42
+     * @var string[]
43
+     */
44 44
     protected $strings = array();
45 45
 
46
-   /**
47
-    * @var string
48
-    */
46
+    /**
47
+     * @var string
48
+     */
49 49
     protected $mode = 'html';
50 50
 
51
-   /**
52
-    * @var string
53
-    */
51
+    /**
52
+     * @var string
53
+     */
54 54
     protected $noSpace = '§!§';
55 55
     
56 56
     public function __construct()
@@ -58,12 +58,12 @@  discard block
 block discarded – undo
58 58
         
59 59
     }
60 60
     
61
-   /**
62
-    * Adds a subject as a string. Is ignored if empty.
63
-    * 
64
-    * @param string|number|StringBuilder_Interface $string
65
-    * @return $this
66
-    */
61
+    /**
62
+     * Adds a subject as a string. Is ignored if empty.
63
+     * 
64
+     * @param string|number|StringBuilder_Interface $string
65
+     * @return $this
66
+     */
67 67
     public function add($string) : StringBuilder
68 68
     {
69 69
         $string = strval($string);
@@ -76,57 +76,57 @@  discard block
 block discarded – undo
76 76
         return $this;
77 77
     }
78 78
     
79
-   /**
80
-    * Adds a string without appending an automatic space.
81
-    * 
82
-    * @param string|number|StringBuilder_Interface $string
83
-    * @return $this
84
-    */
79
+    /**
80
+     * Adds a string without appending an automatic space.
81
+     * 
82
+     * @param string|number|StringBuilder_Interface $string
83
+     * @return $this
84
+     */
85 85
     public function nospace($string) : StringBuilder
86 86
     {
87 87
         return $this->add($this->noSpace.strval($string));
88 88
     }
89 89
     
90
-   /**
91
-    * Adds raw HTML code. Does not add an automatic space.
92
-    * 
93
-    * @param string|number|StringBuilder_Interface $html
94
-    * @return $this
95
-    */
90
+    /**
91
+     * Adds raw HTML code. Does not add an automatic space.
92
+     * 
93
+     * @param string|number|StringBuilder_Interface $html
94
+     * @return $this
95
+     */
96 96
     public function html($html) : StringBuilder
97 97
     {
98 98
         return $this->nospace($html);
99 99
     }
100 100
     
101
-   /**
102
-    * Adds an unordered list with the specified items.
103
-    * 
104
-    * @param array<int,string|number|StringBuilder_Interface> $items
105
-    * @return $this
106
-    */
101
+    /**
102
+     * Adds an unordered list with the specified items.
103
+     * 
104
+     * @param array<int,string|number|StringBuilder_Interface> $items
105
+     * @return $this
106
+     */
107 107
     public function ul(array $items) : StringBuilder
108 108
     {
109 109
         return $this->list('ul', $items);
110 110
     }
111 111
     
112
-   /**
113
-    * Adds an ordered list with the specified items.
114
-    * 
115
-    * @param array<int,string|number|StringBuilder_Interface> $items
116
-    * @return $this
117
-    */
112
+    /**
113
+     * Adds an ordered list with the specified items.
114
+     * 
115
+     * @param array<int,string|number|StringBuilder_Interface> $items
116
+     * @return $this
117
+     */
118 118
     public function ol(array $items) : StringBuilder
119 119
     {
120 120
         return $this->list('ol', $items);
121 121
     }
122 122
     
123
-   /**
124
-    * Creates a list tag with the items list.
125
-    * 
126
-    * @param string $type The list type, `ol` or `ul`.
127
-    * @param array<int,string|number|StringBuilder_Interface> $items
128
-    * @return $this
129
-    */
123
+    /**
124
+     * Creates a list tag with the items list.
125
+     * 
126
+     * @param string $type The list type, `ol` or `ul`.
127
+     * @param array<int,string|number|StringBuilder_Interface> $items
128
+     * @return $this
129
+     */
130 130
     protected function list(string $type, array $items) : StringBuilder
131 131
     {
132 132
         return $this->html(sprintf(
@@ -136,13 +136,13 @@  discard block
 block discarded – undo
136 136
         ));
137 137
     }
138 138
     
139
-   /**
140
-    * Add a translated string.
141
-    * 
142
-    * @param string $format The native string to translate.
143
-    * @param array<int,mixed> $arguments The variables to inject into the translated string, if any.
144
-    * @return $this
145
-    */
139
+    /**
140
+     * Add a translated string.
141
+     * 
142
+     * @param string $format The native string to translate.
143
+     * @param array<int,mixed> $arguments The variables to inject into the translated string, if any.
144
+     * @return $this
145
+     */
146 146
     public function t(string $format, ...$arguments) : StringBuilder
147 147
     {
148 148
         if(!class_exists('\AppLocalize\Localization'))
@@ -195,36 +195,36 @@  discard block
 block discarded – undo
195 195
         return $this->add(ConvertHelper::duration2string($since));
196 196
     }
197 197
     
198
-   /**
199
-    * Adds HTML double quotes around the string.
200
-    * 
201
-    * @param string|number|StringBuilder_Interface $string
202
-    * @return $this
203
-    */
198
+    /**
199
+     * Adds HTML double quotes around the string.
200
+     * 
201
+     * @param string|number|StringBuilder_Interface $string
202
+     * @return $this
203
+     */
204 204
     public function quote($string)
205 205
     {
206 206
         return $this->sf('&quot;%s&quot;', strval($string));
207 207
     }
208 208
     
209
-   /**
210
-    * Adds a text that is meant as a reference to an UI element,
211
-    * like a menu item, button, etc.
212
-    * 
213
-    * @param string|number|StringBuilder_Interface $string 
214
-    * @return $this
215
-    */
209
+    /**
210
+     * Adds a text that is meant as a reference to an UI element,
211
+     * like a menu item, button, etc.
212
+     * 
213
+     * @param string|number|StringBuilder_Interface $string 
214
+     * @return $this
215
+     */
216 216
     public function reference($string) : StringBuilder
217 217
     {
218 218
         return $this->sf('"%s"', $string);
219 219
     }
220 220
 
221
-   /**
222
-    * Add a string using the `sprintf` method.
223
-    * 
224
-    * @param string $format The format string
225
-    * @param string|number|StringBuilder_Interface ...$arguments The variables to inject
226
-    * @return $this
227
-    */
221
+    /**
222
+     * Add a string using the `sprintf` method.
223
+     * 
224
+     * @param string $format The format string
225
+     * @param string|number|StringBuilder_Interface ...$arguments The variables to inject
226
+     * @return $this
227
+     */
228 228
     public function sf(string $format, ...$arguments) : StringBuilder
229 229
     {
230 230
         array_unshift($arguments, $format);
@@ -232,12 +232,12 @@  discard block
 block discarded – undo
232 232
         return $this->add(call_user_func_array('sprintf', $arguments));
233 233
     }
234 234
     
235
-   /**
236
-    * Adds a bold string.
237
-    * 
238
-    * @param string|number|StringBuilder_Interface $string
239
-    * @return $this
240
-    */
235
+    /**
236
+     * Adds a bold string.
237
+     * 
238
+     * @param string|number|StringBuilder_Interface $string
239
+     * @return $this
240
+     */
241 241
     public function bold($string) : StringBuilder
242 242
     {
243 243
         return $this->sf(
@@ -246,15 +246,15 @@  discard block
 block discarded – undo
246 246
         );
247 247
     }
248 248
     
249
-   /**
250
-    * Adds an HTML `<br>` tag.
251
-    *
252
-    * Note: for adding a newline character instead,
253
-    * use {@see StringBuilder::eol()}.
254
-    * 
255
-    * @return $this
256
-    * @see StringBuilder::eol()
257
-    */
249
+    /**
250
+     * Adds an HTML `<br>` tag.
251
+     *
252
+     * Note: for adding a newline character instead,
253
+     * use {@see StringBuilder::eol()}.
254
+     * 
255
+     * @return $this
256
+     * @see StringBuilder::eol()
257
+     */
258 258
     public function nl() : StringBuilder
259 259
     {
260 260
         return $this->html('<br>');
@@ -271,42 +271,42 @@  discard block
 block discarded – undo
271 271
         return $this->nospace(PHP_EOL);
272 272
     }
273 273
     
274
-   /**
275
-    * Adds the current time, in the format <code>H:i:s</code>.
276
-    * 
277
-    * @return $this
278
-    */
274
+    /**
275
+     * Adds the current time, in the format <code>H:i:s</code>.
276
+     * 
277
+     * @return $this
278
+     */
279 279
     public function time() : StringBuilder
280 280
     {
281 281
         return $this->add(date('H:i:s'));
282 282
     }
283 283
     
284
-   /**
285
-    * Adds the "Note:" text.
286
-    * 
287
-    * @return $this
288
-    */
284
+    /**
285
+     * Adds the "Note:" text.
286
+     * 
287
+     * @return $this
288
+     */
289 289
     public function note() : StringBuilder
290 290
     {
291 291
         return $this->t('Note:');
292 292
     }
293 293
     
294
-   /**
295
-    * Like {@see StringBuilder::note()}, but as bold text.
296
-    * 
297
-    * @return $this
298
-    */
294
+    /**
295
+     * Like {@see StringBuilder::note()}, but as bold text.
296
+     * 
297
+     * @return $this
298
+     */
299 299
     public function noteBold() : StringBuilder
300 300
     {
301 301
         return $this->bold(sb()->note());
302 302
     }
303 303
     
304
-   /**
305
-    * Adds the "Hint:" text.
306
-    * 
307
-    * @return $this
308
-    * @see StringBuilder::hintBold()
309
-    */
304
+    /**
305
+     * Adds the "Hint:" text.
306
+     * 
307
+     * @return $this
308
+     * @see StringBuilder::hintBold()
309
+     */
310 310
     public function hint() : StringBuilder
311 311
     {
312 312
         return $this->t('Hint:');
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
         return $this->bold(sb()->hint());
323 323
     }
324 324
     
325
-   /**
326
-    * Adds two linebreaks.
327
-    *
328
-    * @param StringBuilder_Interface|string|NULL $content
329
-    * @return $this
330
-    */
325
+    /**
326
+     * Adds two linebreaks.
327
+     *
328
+     * @param StringBuilder_Interface|string|NULL $content
329
+     * @return $this
330
+     */
331 331
     public function para($content=null) : StringBuilder
332 332
     {
333 333
         if($content !== null) {
@@ -337,14 +337,14 @@  discard block
 block discarded – undo
337 337
         return $this->nl()->nl();
338 338
     }
339 339
     
340
-   /**
341
-    * Adds an anchor HTML tag.
342
-    * 
343
-    * @param string $label
344
-    * @param string $url
345
-    * @param bool $newTab
346
-    * @return $this
347
-    */
340
+    /**
341
+     * Adds an anchor HTML tag.
342
+     * 
343
+     * @param string $label
344
+     * @param string $url
345
+     * @param bool $newTab
346
+     * @return $this
347
+     */
348 348
     public function link(string $label, string $url, bool $newTab=false) : StringBuilder
349 349
     {
350 350
         $target = '';
@@ -360,12 +360,12 @@  discard block
 block discarded – undo
360 360
         );
361 361
     }
362 362
     
363
-   /**
364
-    * Wraps the string in a `code` tag.
365
-    * 
366
-    * @param string|number|StringBuilder_Interface $string
367
-    * @return $this
368
-    */
363
+    /**
364
+     * Wraps the string in a `code` tag.
365
+     * 
366
+     * @param string|number|StringBuilder_Interface $string
367
+     * @return $this
368
+     */
369 369
     public function code($string) : StringBuilder
370 370
     {
371 371
         return $this->sf(
@@ -374,24 +374,24 @@  discard block
 block discarded – undo
374 374
         );
375 375
     }
376 376
     
377
-   /**
378
-    * Wraps the string in a `pre` tag.
379
-    * 
380
-    * @param string|number|StringBuilder_Interface $string
381
-    * @return $this
382
-    */
377
+    /**
378
+     * Wraps the string in a `pre` tag.
379
+     * 
380
+     * @param string|number|StringBuilder_Interface $string
381
+     * @return $this
382
+     */
383 383
     public function pre($string) : StringBuilder
384 384
     {
385 385
         return $this->sf('<pre>%s</pre>', strval($string));
386 386
     }
387 387
     
388
-   /**
389
-    * Wraps the text in a `span` tag with the specified classes.
390
-    * 
391
-    * @param string|number|StringBuilder_Interface $string
392
-    * @param string|string[] $classes
393
-    * @return $this
394
-    */
388
+    /**
389
+     * Wraps the text in a `span` tag with the specified classes.
390
+     * 
391
+     * @param string|number|StringBuilder_Interface $string
392
+     * @param string|string[] $classes
393
+     * @return $this
394
+     */
395 395
     public function spanned($string, $classes) : StringBuilder
396 396
     {
397 397
         if(!is_array($classes)) 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         $string = strval($string);
70 70
         
71
-        if(!empty($string)) 
71
+        if (!empty($string)) 
72 72
         {
73 73
             $this->strings[] = $string;
74 74
         }
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
     */
146 146
     public function t(string $format, ...$arguments) : StringBuilder
147 147
     {
148
-        if(!class_exists('\AppLocalize\Localization'))
148
+        if (!class_exists('\AppLocalize\Localization'))
149 149
         {
150 150
             array_unshift($arguments, $format);
151 151
             return $this->sf(...$arguments);
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
     {
171 171
         unset($context); // Only used by the localization parser.
172 172
 
173
-        if(!class_exists('\AppLocalize\Localization'))
173
+        if (!class_exists('\AppLocalize\Localization'))
174 174
         {
175 175
             array_unshift($arguments, $format);
176 176
             return $this->sf(...$arguments);
@@ -328,9 +328,9 @@  discard block
 block discarded – undo
328 328
     * @param StringBuilder_Interface|string|NULL $content
329 329
     * @return $this
330 330
     */
331
-    public function para($content=null) : StringBuilder
331
+    public function para($content = null) : StringBuilder
332 332
     {
333
-        if($content !== null) {
333
+        if ($content !== null) {
334 334
             return $this->html('<p>')->nospace($content)->html('</p>');
335 335
         }
336 336
 
@@ -345,10 +345,10 @@  discard block
 block discarded – undo
345 345
     * @param bool $newTab
346 346
     * @return $this
347 347
     */
348
-    public function link(string $label, string $url, bool $newTab=false) : StringBuilder
348
+    public function link(string $label, string $url, bool $newTab = false) : StringBuilder
349 349
     {
350 350
         $target = '';
351
-        if($newTab) {
351
+        if ($newTab) {
352 352
             $target = ' target="_blank"';
353 353
         }
354 354
        
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
     */
395 395
     public function spanned($string, $classes) : StringBuilder
396 396
     {
397
-        if(!is_array($classes)) 
397
+        if (!is_array($classes)) 
398 398
         {
399 399
             $classes = array(strval($classes));
400 400
         }
Please login to merge, or discard this patch.
src/OutputBuffering.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     {
69 69
         self::$stack[] = 1;
70 70
 
71
-        if(ob_start() === true) {
71
+        if (ob_start() === true) {
72 72
             return;
73 73
         }
74 74
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
     {
91 91
         self::_stop();
92 92
 
93
-        if(ob_end_clean() !== false)
93
+        if (ob_end_clean() !== false)
94 94
         {
95 95
             return;
96 96
         }
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
      */
108 108
     private static function _stop() : void
109 109
     {
110
-        if(empty(self::$stack))
110
+        if (empty(self::$stack))
111 111
         {
112 112
             throw new OutputBuffering_Exception(
113 113
                 'Output buffering is not active',
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
     {
131 131
         self::_stop();
132 132
 
133
-        if(ob_end_flush() !== false)
133
+        if (ob_end_flush() !== false)
134 134
         {
135 135
             return;
136 136
         }
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 
159 159
         $content = ob_get_clean();
160 160
 
161
-        if($content !== false)
161
+        if ($content !== false)
162 162
         {
163 163
             return $content;
164 164
         }
Please login to merge, or discard this patch.