Passed
Push — master ( b083ab...a3db06 )
by Sebastian
03:30
created
src/Microtime.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -114,9 +114,9 @@  discard block
 block discarded – undo
114 114
      * @see Microtime::createFromString()
115 115
      * @see Microtime::createNow()
116 116
      */
117
-    public function __construct($datetime=self::DATETIME_NOW, ?DateTimeZone $timeZone=null)
117
+    public function __construct($datetime = self::DATETIME_NOW, ?DateTimeZone $timeZone = null)
118 118
     {
119
-        if($datetime instanceof Microtime_ParseResult)
119
+        if ($datetime instanceof Microtime_ParseResult)
120 120
         {
121 121
             $parsed = $datetime;
122 122
         }
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
      * @return Microtime_ParseResult
149 149
      * @throws Microtime_Exception
150 150
      */
151
-    private function parseDate($datetime, ?DateTimeZone $timeZone=null) : Microtime_ParseResult
151
+    private function parseDate($datetime, ?DateTimeZone $timeZone = null) : Microtime_ParseResult
152 152
     {
153
-        if($datetime instanceof Microtime)
153
+        if ($datetime instanceof Microtime)
154 154
         {
155 155
             return new Microtime_ParseResult(
156 156
                 $datetime->getISODate(),
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
             );
159 159
         }
160 160
 
161
-        if($datetime instanceof DateTime)
161
+        if ($datetime instanceof DateTime)
162 162
         {
163 163
             return new Microtime_ParseResult(
164 164
                 $datetime->format(self::FORMAT_ISO),
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
             );
167 167
         }
168 168
 
169
-        if($timeZone === null)
169
+        if ($timeZone === null)
170 170
         {
171 171
             $timeZone = new DateTimeZone(date_default_timezone_get());
172 172
         }
173 173
 
174
-        if(empty($datetime) || $datetime === self::DATETIME_NOW)
174
+        if (empty($datetime) || $datetime === self::DATETIME_NOW)
175 175
         {
176 176
             return self::parseNow($timeZone);
177 177
         }
178 178
 
179
-        if(is_string($datetime))
179
+        if (is_string($datetime))
180 180
         {
181 181
             return new Microtime_ParseResult(
182 182
                 $datetime,
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
     {
204 204
         $dateObj = DateTime::createFromFormat('0.u00 U', microtime(), new DateTimeZone('America/Denver'));
205 205
 
206
-        if($dateObj !== false)
206
+        if ($dateObj !== false)
207 207
         {
208 208
             $dateObj->setTimezone($timeZone);
209 209
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
      * @return Microtime
228 228
      * @throws Microtime_Exception
229 229
      */
230
-    public static function createNow(?DateTimeZone $timeZone=null) : Microtime
230
+    public static function createNow(?DateTimeZone $timeZone = null) : Microtime
231 231
     {
232
-        if($timeZone === null)
232
+        if ($timeZone === null)
233 233
         {
234 234
             $timeZone = new DateTimeZone(date_default_timezone_get());
235 235
         }
@@ -246,9 +246,9 @@  discard block
 block discarded – undo
246 246
      * @return Microtime
247 247
      * @throws Microtime_Exception
248 248
      */
249
-    public static function createFromString(string $date, ?DateTimeZone $timeZone=null) : Microtime
249
+    public static function createFromString(string $date, ?DateTimeZone $timeZone = null) : Microtime
250 250
     {
251
-        if($timeZone === null)
251
+        if ($timeZone === null)
252 252
         {
253 253
             $timeZone = new DateTimeZone(date_default_timezone_get());
254 254
         }
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -119,8 +119,7 @@  discard block
 block discarded – undo
119 119
         if($datetime instanceof Microtime_ParseResult)
120 120
         {
121 121
             $parsed = $datetime;
122
-        }
123
-        else
122
+        } else
124 123
         {
125 124
             $parsed = $this->parseDate($datetime, $timeZone);
126 125
         }
@@ -128,8 +127,7 @@  discard block
 block discarded – undo
128 127
         try
129 128
         {
130 129
             parent::__construct($parsed->getDateTime(), $parsed->getTimeZone());
131
-        }
132
-        catch (Exception $e)
130
+        } catch (Exception $e)
133 131
         {
134 132
             throw new Microtime_Exception(
135 133
                 'Failed to create date from string.',
Please login to merge, or discard this patch.
src/ConvertHelper/ThrowableInfo.php 3 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function __construct($subject)
82 82
     {
83
-        if(is_array($subject))
83
+        if (is_array($subject))
84 84
         {
85 85
             $this->parseSerialized($subject);
86 86
         }
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
     */
140 140
     public function getPrevious() : ConvertHelper_ThrowableInfo
141 141
     {
142
-        if(isset($this->previous)) {
142
+        if (isset($this->previous)) {
143 143
             return $this->previous;
144 144
         }
145 145
         
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
     public function getFolderDepth() : int
259 259
     {
260 260
         $depth = $this->getOption('folder-depth');
261
-        if(!empty($depth)) {
261
+        if (!empty($depth)) {
262 262
             return $depth;
263 263
         }
264 264
         
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 
316 316
         $this->setOptions($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_OPTIONS]);
317 317
         
318
-        foreach($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_CALLS] as $def)
318
+        foreach ($serialized[ConvertHelper_ThrowableInfo_Serializer::SERIALIZED_CALLS] as $def)
319 319
         {
320 320
             $this->calls[] = ConvertHelper_ThrowableInfo_Call::fromSerialized($this, $def);
321 321
         }
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         $this->date = new Microtime();
327 327
         $this->class = get_class($e);
328 328
 
329
-        if($e instanceof BaseException)
329
+        if ($e instanceof BaseException)
330 330
         {
331 331
             $this->details = $e->getDetails();
332 332
         }
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
      * @return string
360 360
      * @throws ConvertHelper_Exception
361 361
      */
362
-    public function renderErrorMessage(bool $withDeveloperInfo=false) : string
362
+    public function renderErrorMessage(bool $withDeveloperInfo = false) : string
363 363
     {
364 364
         return (new ConvertHelper_ThrowableInfo_MessageRenderer($this, $withDeveloperInfo))
365 365
             ->render();
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
         }
436 436
         else
437 437
         {
438
-            $this->message = 'Original error code: [' . $code . ']. ' . $this->message;
438
+            $this->message = 'Original error code: ['.$code.']. '.$this->message;
439 439
         }
440 440
     }
441 441
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -83,8 +83,7 @@  discard block
 block discarded – undo
83 83
         if(is_array($subject))
84 84
         {
85 85
             $this->parseSerialized($subject);
86
-        }
87
-        else
86
+        } else
88 87
         {
89 88
             $this->parseException($subject);
90 89
         }
@@ -432,8 +431,7 @@  discard block
 block discarded – undo
432 431
         if (is_integer($code))
433 432
         {
434 433
             $this->code = $code;
435
-        }
436
-        else
434
+        } else
437 435
         {
438 436
             $this->message = 'Original error code: [' . $code . ']. ' . $this->message;
439 437
         }
Please login to merge, or discard this patch.
Indentation   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -20,48 +20,48 @@  discard block
 block discarded – undo
20 20
     public const CONTEXT_WEB = 'web';
21 21
 
22 22
     /**
23
-    * @var Throwable
24
-    */
23
+     * @var Throwable
24
+     */
25 25
     protected $exception;
26 26
     
27
-   /**
28
-    * @var ConvertHelper_ThrowableInfo_Call[]
29
-    */
27
+    /**
28
+     * @var ConvertHelper_ThrowableInfo_Call[]
29
+     */
30 30
     protected $calls = array();
31 31
     
32
-   /**
33
-    * @var integer
34
-    */
32
+    /**
33
+     * @var integer
34
+     */
35 35
     protected $code = 0;
36 36
     
37
-   /**
38
-    * @var string
39
-    */
37
+    /**
38
+     * @var string
39
+     */
40 40
     protected $message;
41 41
     
42
-   /**
43
-    * @var integer
44
-    */
42
+    /**
43
+     * @var integer
44
+     */
45 45
     protected $callsCount = 0;
46 46
     
47
-   /**
48
-    * @var ConvertHelper_ThrowableInfo|NULL
49
-    */
47
+    /**
48
+     * @var ConvertHelper_ThrowableInfo|NULL
49
+     */
50 50
     protected $previous = null;
51 51
     
52
-   /**
53
-    * @var string
54
-    */
52
+    /**
53
+     * @var string
54
+     */
55 55
     protected $referer = '';
56 56
     
57
-   /**
58
-    * @var Microtime
59
-    */
57
+    /**
58
+     * @var Microtime
59
+     */
60 60
     protected $date;
61 61
     
62
-   /**
63
-    * @var string
64
-    */
62
+    /**
63
+     * @var string
64
+     */
65 65
     protected $context = self::CONTEXT_WEB;
66 66
 
67 67
     /**
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
         return isset($this->previous);
128 128
     }
129 129
     
130
-   /**
131
-    * Retrieves the information on the previous exception.
132
-    * 
133
-    * NOTE: Throws an exception if there is no previous 
134
-    * exception. Use hasPrevious() first to avoid this.
135
-    * 
136
-    * @throws ConvertHelper_Exception
137
-    * @return ConvertHelper_ThrowableInfo
138
-    * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
139
-    */
130
+    /**
131
+     * Retrieves the information on the previous exception.
132
+     * 
133
+     * NOTE: Throws an exception if there is no previous 
134
+     * exception. Use hasPrevious() first to avoid this.
135
+     * 
136
+     * @throws ConvertHelper_Exception
137
+     * @return ConvertHelper_ThrowableInfo
138
+     * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
139
+     */
140 140
     public function getPrevious() : ConvertHelper_ThrowableInfo
141 141
     {
142 142
         if(isset($this->previous)) {
@@ -155,68 +155,68 @@  discard block
 block discarded – undo
155 155
         return !empty($this->code);
156 156
     }
157 157
     
158
-   /**
159
-    * Improved text-only exception trace.
160
-    */
158
+    /**
159
+     * Improved text-only exception trace.
160
+     */
161 161
     public function toString() : string
162 162
     {
163 163
         return (new ConvertHelper_ThrowableInfo_StringConverter($this))
164 164
             ->toString();
165 165
     }
166 166
     
167
-   /**
168
-    * Retrieves the URL of the page in which the exception
169
-    * was thrown, if applicable: in CLI context, this will
170
-    * return an empty string.
171
-    * 
172
-    * @return string
173
-    */
167
+    /**
168
+     * Retrieves the URL of the page in which the exception
169
+     * was thrown, if applicable: in CLI context, this will
170
+     * return an empty string.
171
+     * 
172
+     * @return string
173
+     */
174 174
     public function getReferer() : string
175 175
     {
176 176
         return $this->referer;
177 177
     }
178 178
     
179
-   /**
180
-    * Whether the exception occurred in a command line context.
181
-    * @return bool
182
-    */
179
+    /**
180
+     * Whether the exception occurred in a command line context.
181
+     * @return bool
182
+     */
183 183
     public function isCommandLine() : bool
184 184
     {
185 185
         return $this->getContext() === self::CONTEXT_COMMAND_LINE;
186 186
     }
187 187
     
188
-   /**
189
-    * Whether the exception occurred during an http request.
190
-    * @return bool
191
-    */
188
+    /**
189
+     * Whether the exception occurred during an http request.
190
+     * @return bool
191
+     */
192 192
     public function isWebRequest() : bool
193 193
     {
194 194
         return $this->getContext() === self::CONTEXT_WEB;
195 195
     }
196 196
     
197
-   /**
198
-    * Retrieves the context identifier, i.e. if the exception
199
-    * occurred in a command line context or regular web request.
200
-    * 
201
-    * @return string
202
-    * 
203
-    * @see ConvertHelper_ThrowableInfo::isCommandLine()
204
-    * @see ConvertHelper_ThrowableInfo::isWebRequest()
205
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
206
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
207
-    */
197
+    /**
198
+     * Retrieves the context identifier, i.e. if the exception
199
+     * occurred in a command line context or regular web request.
200
+     * 
201
+     * @return string
202
+     * 
203
+     * @see ConvertHelper_ThrowableInfo::isCommandLine()
204
+     * @see ConvertHelper_ThrowableInfo::isWebRequest()
205
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
206
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
207
+     */
208 208
     public function getContext() : string
209 209
     {
210 210
         return $this->context;
211 211
     }
212 212
     
213
-   /**
214
-    * Retrieves the date of the exception, and approximate time:
215
-    * since exceptions do not store time, this is captured the 
216
-    * moment the ThrowableInfo is created.
217
-    * 
218
-    * @return Microtime
219
-    */
213
+    /**
214
+     * Retrieves the date of the exception, and approximate time:
215
+     * since exceptions do not store time, this is captured the 
216
+     * moment the ThrowableInfo is created.
217
+     * 
218
+     * @return Microtime
219
+     */
220 220
     public function getDate() : Microtime
221 221
     {
222 222
         return $this->date;
@@ -237,24 +237,24 @@  discard block
 block discarded – undo
237 237
         return ConvertHelper_ThrowableInfo_Serializer::serialize($this);
238 238
     }
239 239
 
240
-   /**
241
-    * Sets the maximum folder depth to show in the 
242
-    * file paths, to avoid them being too long.
243
-    * 
244
-    * @param int $depth
245
-    * @return ConvertHelper_ThrowableInfo
246
-    */
240
+    /**
241
+     * Sets the maximum folder depth to show in the 
242
+     * file paths, to avoid them being too long.
243
+     * 
244
+     * @param int $depth
245
+     * @return ConvertHelper_ThrowableInfo
246
+     */
247 247
     public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo
248 248
     {
249 249
         return $this->setOption('folder-depth', $depth);
250 250
     }
251 251
     
252
-   /**
253
-    * Retrieves the current folder depth option value.
254
-    * 
255
-    * @return int
256
-    * @see ConvertHelper_ThrowableInfo::setFolderDepth()
257
-    */
252
+    /**
253
+     * Retrieves the current folder depth option value.
254
+     * 
255
+     * @return int
256
+     * @see ConvertHelper_ThrowableInfo::setFolderDepth()
257
+     */
258 258
     public function getFolderDepth() : int
259 259
     {
260 260
         $depth = $this->getOption('folder-depth');
@@ -265,13 +265,13 @@  discard block
 block discarded – undo
265 265
         return 2;
266 266
     }
267 267
     
268
-   /**
269
-    * Retrieves all function calls that led to the error,
270
-    * ordered from latest to earliest (the first one in
271
-    * the stack is actually the last call).
272
-    *
273
-    * @return ConvertHelper_ThrowableInfo_Call[]
274
-    */
268
+    /**
269
+     * Retrieves all function calls that led to the error,
270
+     * ordered from latest to earliest (the first one in
271
+     * the stack is actually the last call).
272
+     *
273
+     * @return ConvertHelper_ThrowableInfo_Call[]
274
+     */
275 275
     public function getCalls()
276 276
     {
277 277
         return $this->calls;
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
         return $this->calls[0];
288 288
     }
289 289
     
290
-   /**
291
-    * Returns the amount of function and method calls in the stack trace.
292
-    * @return int
293
-    */
290
+    /**
291
+     * Returns the amount of function and method calls in the stack trace.
292
+     * @return int
293
+     */
294 294
     public function countCalls() : int
295 295
     {
296 296
         return $this->callsCount;
Please login to merge, or discard this patch.
src/ConvertHelper/ThrowableInfo/MessageRenderer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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()
Please login to merge, or discard this patch.
src/ConvertHelper/ThrowableInfo/StringConverter.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/ZIPHelper.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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(
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         
Please login to merge, or discard this patch.
src/Transliteration.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/XMLHelper.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -28,9 +28,9 @@  discard block
 block discarded – undo
28 28
 {
29 29
     public const ERROR_CANNOT_APPEND_FRAGMENT = 491001; 
30 30
 
31
-   /**
32
-    * @var boolean
33
-    */
31
+    /**
32
+     * @var boolean
33
+     */
34 34
     private static $simulation = false;
35 35
 
36 36
     /**
@@ -38,11 +38,11 @@  discard block
 block discarded – undo
38 38
      */
39 39
     private $dom;
40 40
     
41
-   /**
42
-    * Creates a new XMLHelper instance.
43
-    * 
44
-    * @return XMLHelper
45
-    */
41
+    /**
42
+     * Creates a new XMLHelper instance.
43
+     * 
44
+     * @return XMLHelper
45
+     */
46 46
     public static function create() : XMLHelper
47 47
     {
48 48
         $dom = new DOMDocument('1.0', 'UTF-8');
@@ -51,72 +51,72 @@  discard block
 block discarded – undo
51 51
         return new XMLHelper($dom);
52 52
     }
53 53
     
54
-   /**
55
-    * Creates a converter instance from an XML file.
56
-    * @param string $xmlFile
57
-    * @return XMLHelper_Converter
58
-    */
54
+    /**
55
+     * Creates a converter instance from an XML file.
56
+     * @param string $xmlFile
57
+     * @return XMLHelper_Converter
58
+     */
59 59
     public static function convertFile(string $xmlFile) : XMLHelper_Converter
60 60
     {
61 61
         return XMLHelper_Converter::fromFile($xmlFile);
62 62
     }
63 63
     
64
-   /**
65
-    * Creates a converter from an XML string.
66
-    * @param string $xmlString
67
-    * @return XMLHelper_Converter
68
-    */
64
+    /**
65
+     * Creates a converter from an XML string.
66
+     * @param string $xmlString
67
+     * @return XMLHelper_Converter
68
+     */
69 69
     public static function convertString(string $xmlString) : XMLHelper_Converter
70 70
     {
71 71
         return XMLHelper_Converter::fromString($xmlString);
72 72
     }
73 73
 
74
-   /**
75
-    * Creates a converter from a SimpleXMLElement instance.
76
-    * @param SimpleXMLElement $element
77
-    * @return XMLHelper_Converter
78
-    */
74
+    /**
75
+     * Creates a converter from a SimpleXMLElement instance.
76
+     * @param SimpleXMLElement $element
77
+     * @return XMLHelper_Converter
78
+     */
79 79
     public static function convertElement(SimpleXMLElement $element) : XMLHelper_Converter
80 80
     {
81 81
         return XMLHelper_Converter::fromElement($element);
82 82
     }
83 83
    
84
-   /**
85
-    * Creates a converter from a DOMElement instance.
86
-    * @param DOMElement $element
87
-    * @return XMLHelper_Converter
88
-    */
84
+    /**
85
+     * Creates a converter from a DOMElement instance.
86
+     * @param DOMElement $element
87
+     * @return XMLHelper_Converter
88
+     */
89 89
     public static function convertDOMElement(DOMElement $element) : XMLHelper_Converter
90 90
     {
91 91
         return XMLHelper_Converter::fromDOMElement($element);
92 92
     }
93 93
 
94
-   /**
95
-    * Creates a new helper using an existing DOMDocument object.
96
-    * @param DOMDocument $dom
97
-    */
94
+    /**
95
+     * Creates a new helper using an existing DOMDocument object.
96
+     * @param DOMDocument $dom
97
+     */
98 98
     public function __construct(DOMDocument $dom)
99 99
     {
100 100
         $this->dom = $dom;
101 101
     }
102 102
 
103
-   /**
104
-    * @return DOMDocument
105
-    */
103
+    /**
104
+     * @return DOMDocument
105
+     */
106 106
     public function getDOM() : DOMDocument
107 107
     {
108 108
         return $this->dom;
109 109
     }
110 110
 
111
-   /**
112
-    * Adds an attribute to an existing tag with
113
-    * the specified value.
114
-    *
115
-    * @param DOMNode $parent
116
-    * @param string $name
117
-    * @param mixed $value
118
-    * @return DOMNode
119
-    */
111
+    /**
112
+     * Adds an attribute to an existing tag with
113
+     * the specified value.
114
+     *
115
+     * @param DOMNode $parent
116
+     * @param string $name
117
+     * @param mixed $value
118
+     * @return DOMNode
119
+     */
120 120
     public function addAttribute(DOMNode $parent, string $name, $value)
121 121
     {
122 122
         $node = $this->dom->createAttribute($name);
@@ -126,12 +126,12 @@  discard block
 block discarded – undo
126 126
         return $parent->appendChild($node);
127 127
     }
128 128
 
129
-   /**
130
-    * Adds several attributes to the target node.
131
-    * 
132
-    * @param DOMNode $parent
133
-    * @param array<string,mixed> $attributes
134
-    */
129
+    /**
130
+     * Adds several attributes to the target node.
131
+     * 
132
+     * @param DOMNode $parent
133
+     * @param array<string,mixed> $attributes
134
+     */
135 135
     public function addAttributes(DOMNode $parent, array $attributes) : void
136 136
     {
137 137
         foreach ($attributes as $name => $value) {
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
         }
140 140
     }
141 141
 
142
-   /**
143
-    * Adds a tag without content.
144
-    *
145
-    * @param DOMNode $parent
146
-    * @param string $name
147
-    * @param integer $indent
148
-    * @return DOMNode
149
-    */
142
+    /**
143
+     * Adds a tag without content.
144
+     *
145
+     * @param DOMNode $parent
146
+     * @param string $name
147
+     * @param integer $indent
148
+     * @return DOMNode
149
+     */
150 150
     public function addTag(DOMNode $parent, string $name, int $indent = 0) : DOMNode
151 151
     {
152 152
         if ($indent > 0) {
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
         $parent->appendChild($this->dom->createTextNode(str_repeat("\t", $amount)));
169 169
     }
170 170
 
171
-   /**
172
-    * Adds a tag with textual content, like:
173
-    *
174
-    * <tagname>text</tagname>
175
-    *
176
-    * @param DOMNode $parent
177
-    * @param string $name
178
-    * @param string $text
179
-    * @param integer $indent
180
-    * @return DOMNode
181
-    */
171
+    /**
172
+     * Adds a tag with textual content, like:
173
+     *
174
+     * <tagname>text</tagname>
175
+     *
176
+     * @param DOMNode $parent
177
+     * @param string $name
178
+     * @param string $text
179
+     * @param integer $indent
180
+     * @return DOMNode
181
+     */
182 182
     public function addTextTag(DOMNode $parent, string $name, string $text, int $indent = 0) : DOMNode
183 183
     {
184 184
         if ($indent > 0) {
@@ -192,19 +192,19 @@  discard block
 block discarded – undo
192 192
         return $parent->appendChild($tag);
193 193
     }
194 194
 
195
-   /**
196
-    * Adds a tag with textual content, like:
197
-    *
198
-    * <tagname>text</tagname>
199
-    *
200
-    * and removes <p> tags
201
-    *
202
-    * @param DOMNode $parent
203
-    * @param string $name
204
-    * @param string $text
205
-    * @param integer $indent
206
-    * @return DOMNode
207
-    */
195
+    /**
196
+     * Adds a tag with textual content, like:
197
+     *
198
+     * <tagname>text</tagname>
199
+     *
200
+     * and removes <p> tags
201
+     *
202
+     * @param DOMNode $parent
203
+     * @param string $name
204
+     * @param string $text
205
+     * @param integer $indent
206
+     * @return DOMNode
207
+     */
208 208
     public function addEscapedTag(DOMNode $parent, string $name, string $text, int $indent = 0)
209 209
     {
210 210
         if ($indent > 0) {
@@ -220,19 +220,19 @@  discard block
 block discarded – undo
220 220
         return $parent->appendChild($tag);
221 221
     }
222 222
 
223
-   /**
224
-    * Adds a tag with HTML content, like:
225
-    *
226
-    * <tagname><i>text</i></tagname>
227
-    *
228
-    * Tags will not be escaped.
229
-    *
230
-    * @param DOMNode $parent
231
-    * @param string $name
232
-    * @param string $text
233
-    * @param integer $indent
234
-    * @return DOMNode
235
-    */
223
+    /**
224
+     * Adds a tag with HTML content, like:
225
+     *
226
+     * <tagname><i>text</i></tagname>
227
+     *
228
+     * Tags will not be escaped.
229
+     *
230
+     * @param DOMNode $parent
231
+     * @param string $name
232
+     * @param string $text
233
+     * @param integer $indent
234
+     * @return DOMNode
235
+     */
236 236
     public function addFragmentTag(DOMNode $parent, string $name, string $text, int $indent = 0)
237 237
     {
238 238
         if ($indent > 0) {
@@ -260,16 +260,16 @@  discard block
 block discarded – undo
260 260
         return $parent->appendChild($tag);
261 261
     }
262 262
 
263
-   /**
264
-    * Adds a tag with CDATA content, like:
265
-    *
266
-    * <tagname><![CDATA[value]]></tagname>
267
-    *
268
-    * @param DOMNode $parent
269
-    * @param string $name
270
-    * @param string $content
271
-    * @return DOMNode
272
-    */
263
+    /**
264
+     * Adds a tag with CDATA content, like:
265
+     *
266
+     * <tagname><![CDATA[value]]></tagname>
267
+     *
268
+     * @param DOMNode $parent
269
+     * @param string $name
270
+     * @param string $content
271
+     * @return DOMNode
272
+     */
273 273
     public function addCDATATag(DOMNode $parent, string $name, string $content) : DOMNode
274 274
     {
275 275
         $tag = $this->dom->createElement($name);
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
         return $parent->appendChild($tag);
280 280
     }
281 281
 
282
-   /**
283
-    * Creates the root element of the document.
284
-    * @param string $name
285
-    * @param array<string,mixed> $attributes
286
-    * @return DOMNode
287
-    */
282
+    /**
283
+     * Creates the root element of the document.
284
+     * @param string $name
285
+     * @param array<string,mixed> $attributes
286
+     * @return DOMNode
287
+     */
288 288
     public function createRoot(string $name, array $attributes=array())
289 289
     {
290 290
         $root = $this->dom->appendChild($this->dom->createElement($name));
@@ -292,12 +292,12 @@  discard block
 block discarded – undo
292 292
         return $root;
293 293
     }
294 294
 
295
-   /**
296
-    * Escaped the string for use in XML.
297
-    * 
298
-    * @param string $string
299
-    * @return string
300
-    */
295
+    /**
296
+     * Escaped the string for use in XML.
297
+     * 
298
+     * @param string $string
299
+     * @return string
300
+     */
301 301
     public function escape(string $string) : string
302 302
     {
303 303
         $string = preg_replace('#<p>(.*)</p>#isUm', '$1', $string);
@@ -317,18 +317,18 @@  discard block
 block discarded – undo
317 317
         return $string;
318 318
     }
319 319
 
320
-   /**
321
-    * Sends the specified XML string to the browser with
322
-    * the correct headers to trigger a download of the XML
323
-    * to a local file.
324
-    * 
325
-    * NOTE: Ensure calling exit after this is done, and to
326
-    * not send additional content, which would corrupt the 
327
-    * download.
328
-    *
329
-    * @param string $xml
330
-    * @param string $filename
331
-    */
320
+    /**
321
+     * Sends the specified XML string to the browser with
322
+     * the correct headers to trigger a download of the XML
323
+     * to a local file.
324
+     * 
325
+     * NOTE: Ensure calling exit after this is done, and to
326
+     * not send additional content, which would corrupt the 
327
+     * download.
328
+     *
329
+     * @param string $xml
330
+     * @param string $filename
331
+     */
332 332
     public static function downloadXML(string $xml, string $filename = 'download.xml') : void
333 333
     {
334 334
         if(!headers_sent() && !self::$simulation) 
@@ -339,12 +339,12 @@  discard block
 block discarded – undo
339 339
         echo $xml;
340 340
     }
341 341
 
342
-   /**
343
-    * Sends the specified XML string to the browser with
344
-    * the correct headers and terminates the request.
345
-    *
346
-    * @param string $xml
347
-    */
342
+    /**
343
+     * Sends the specified XML string to the browser with
344
+     * the correct headers and terminates the request.
345
+     *
346
+     * @param string $xml
347
+     */
348 348
     public static function displayXML(string $xml) : void
349 349
     {
350 350
         if(!headers_sent() && !self::$simulation) 
@@ -411,23 +411,23 @@  discard block
 block discarded – undo
411 411
         return $xml->saveXML();
412 412
     }
413 413
 
414
-   /**
415
-    * Creates XML markup to describe an application error
416
-    * when using XML services. Creates XML with the
417
-    * following structure:
418
-    *
419
-    * <error>
420
-    *     <id>99</id>
421
-    *     <message>Full error message text</message>
422
-    *     <title>Short error label</title>
423
-    * </error>
424
-    *
425
-    * @param string|number $code
426
-    * @param string $message
427
-    * @param string $title
428
-    * @param array<string,string> $customInfo
429
-    * @return string
430
-    */
414
+    /**
415
+     * Creates XML markup to describe an application error
416
+     * when using XML services. Creates XML with the
417
+     * following structure:
418
+     *
419
+     * <error>
420
+     *     <id>99</id>
421
+     *     <message>Full error message text</message>
422
+     *     <title>Short error label</title>
423
+     * </error>
424
+     *
425
+     * @param string|number $code
426
+     * @param string $message
427
+     * @param string $title
428
+     * @param array<string,string> $customInfo
429
+     * @return string
430
+     */
431 431
     public static function buildErrorXML($code, string $message, string $title, array $customInfo=array())
432 432
     {
433 433
         $xml = new DOMDocument('1.0', 'UTF-8');
@@ -460,31 +460,31 @@  discard block
 block discarded – undo
460 460
         return $this->dom->saveXML();
461 461
     }
462 462
     
463
-   /**
464
-    * Creates a new SimpleXML helper instance: this
465
-    * object is useful to work with loading XML strings
466
-    * and files with easy access to any errors that 
467
-    * may occurr, since the simplexml functions can be
468
-    * somewhat cryptic.
469
-    * 
470
-    * @return XMLHelper_SimpleXML
471
-    */
463
+    /**
464
+     * Creates a new SimpleXML helper instance: this
465
+     * object is useful to work with loading XML strings
466
+     * and files with easy access to any errors that 
467
+     * may occurr, since the simplexml functions can be
468
+     * somewhat cryptic.
469
+     * 
470
+     * @return XMLHelper_SimpleXML
471
+     */
472 472
     public static function createSimplexml() : XMLHelper_SimpleXML
473 473
     {
474 474
         return new XMLHelper_SimpleXML();
475 475
     }
476 476
     
477
-   /**
478
-    * Converts a string to valid XML: can be a text only string
479
-    * or an HTML string. Returns valid XML code.
480
-    * 
481
-    * NOTE: The string may contain custom tags, which are 
482
-    * preserved.
483
-    * 
484
-    * @param string $string
485
-    * @throws XMLHelper_Exception
486
-    * @return string
487
-    */
477
+    /**
478
+     * Converts a string to valid XML: can be a text only string
479
+     * or an HTML string. Returns valid XML code.
480
+     * 
481
+     * NOTE: The string may contain custom tags, which are 
482
+     * preserved.
483
+     * 
484
+     * @param string $string
485
+     * @throws XMLHelper_Exception
486
+     * @return string
487
+     */
488 488
     public static function string2xml(string $string) : string
489 489
     {
490 490
         return XMLHelper_HTMLLoader::loadFragment($string)->fragmentToXML();
Please login to merge, or discard this patch.
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
     public function removeTag(DOMElement $tag) : void
162 162
     {
163
-        if(isset($tag->parentNode))
163
+        if (isset($tag->parentNode))
164 164
         {
165 165
             $tag->parentNode->removeChild($tag);
166 166
         }
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 
247 247
         if (!empty($text)) {
248 248
             $fragment = $this->dom->createDocumentFragment();
249
-            if(!@$fragment->appendXML($text)) {
249
+            if (!@$fragment->appendXML($text)) {
250 250
                 throw new XMLHelper_Exception(
251 251
                     'Cannot append XML fragment',
252 252
                     sprintf(
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
     * @param array<string,mixed> $attributes
289 289
     * @return DOMNode
290 290
     */
291
-    public function createRoot(string $name, array $attributes=array())
291
+    public function createRoot(string $name, array $attributes = array())
292 292
     {
293 293
         $root = $this->dom->appendChild($this->dom->createElement($name));
294 294
         $this->addAttributes($root, $attributes);
@@ -314,8 +314,8 @@  discard block
 block discarded – undo
314 314
         $string = str_replace('&lt;', 'LT_ESCAPE', $string);
315 315
         $string = str_replace('&gt;', 'GT_ESCAPE', $string);
316 316
 
317
-        $string = str_replace('&nbsp;',' ',  $string);
318
-        $string = str_replace('&','&amp;',  $string);
317
+        $string = str_replace('&nbsp;', ' ', $string);
318
+        $string = str_replace('&', '&amp;', $string);
319 319
 
320 320
         return $string;
321 321
     }
@@ -334,9 +334,9 @@  discard block
 block discarded – undo
334 334
     */
335 335
     public static function downloadXML(string $xml, string $filename = 'download.xml') : void
336 336
     {
337
-        if(!headers_sent() && !self::$simulation) 
337
+        if (!headers_sent() && !self::$simulation) 
338 338
         {
339
-            header('Content-Disposition: attachment; filename="' . $filename . '"');
339
+            header('Content-Disposition: attachment; filename="'.$filename.'"');
340 340
         }
341 341
         
342 342
         echo $xml;
@@ -350,12 +350,12 @@  discard block
 block discarded – undo
350 350
     */
351 351
     public static function displayXML(string $xml) : void
352 352
     {
353
-        if(!headers_sent() && !self::$simulation) 
353
+        if (!headers_sent() && !self::$simulation) 
354 354
         {
355 355
             header('Content-Type:text/xml; charset=utf-8');
356 356
         }
357 357
         
358
-        if(self::$simulation) 
358
+        if (self::$simulation) 
359 359
         {
360 360
             $xml = '<pre>'.htmlspecialchars($xml).'</pre>';
361 361
         }
@@ -373,16 +373,16 @@  discard block
 block discarded – undo
373 373
      * @param array<string,string> $customInfo Associative array with name => value pairs for custom tags to add to the output xml
374 374
      * @see buildErrorXML()
375 375
      */
376
-    public static function displayErrorXML($code, string $message, string $title, array $customInfo=array())
376
+    public static function displayErrorXML($code, string $message, string $title, array $customInfo = array())
377 377
     {
378
-        if(!headers_sent() && !self::$simulation) {
379
-            header('HTTP/1.1 400 Bad Request: ' . $title, true, 400);
378
+        if (!headers_sent() && !self::$simulation) {
379
+            header('HTTP/1.1 400 Bad Request: '.$title, true, 400);
380 380
         }
381 381
 
382 382
         self::displayXML(self::buildErrorXML($code, $message, $title, $customInfo));
383 383
     }
384 384
     
385
-    public static function setSimulation(bool $simulate=true) : void
385
+    public static function setSimulation(bool $simulate = true) : void
386 386
     {
387 387
         self::$simulation = $simulate;
388 388
     }
@@ -431,7 +431,7 @@  discard block
 block discarded – undo
431 431
     * @param array<string,string> $customInfo
432 432
     * @return string
433 433
     */
434
-    public static function buildErrorXML($code, string $message, string $title, array $customInfo=array())
434
+    public static function buildErrorXML($code, string $message, string $title, array $customInfo = array())
435 435
     {
436 436
         $xml = new DOMDocument('1.0', 'UTF-8');
437 437
         $xml->formatOutput = true;
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
         $helper->addTextTag($root, 'title', $title);
446 446
         $helper->addTextTag($root, 'request_uri', $_SERVER['REQUEST_URI']);
447 447
         
448
-        foreach($customInfo as $name => $value) {
448
+        foreach ($customInfo as $name => $value) {
449 449
             $helper->addTextTag($root, $name, $value);
450 450
         }
451 451
 
Please login to merge, or discard this patch.
src/HTMLTag/CannedTags.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/ConvertHelper/IntervalConverter.php 2 patches
Indentation   +38 added lines, -39 removed lines patch added patch discarded remove patch
@@ -17,21 +17,20 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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)) {
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         
Please login to merge, or discard this patch.