Passed
Push — master ( 8efc25...9adcd8 )
by Sebastian
02:27
created
src/CSVHelper.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
         
51 51
     }
52 52
 
53
-   /**
54
-    * Creates and returns a new instance of the CSV builder which
55
-    * can be used to build CSV from scratch.
56
-    * 
57
-    * @return CSVHelper_Builder
58
-    */
53
+    /**
54
+     * Creates and returns a new instance of the CSV builder which
55
+     * can be used to build CSV from scratch.
56
+     * 
57
+     * @return CSVHelper_Builder
58
+     */
59 59
     public static function createBuilder()
60 60
     {
61 61
         return new CSVHelper_Builder();
62 62
     }
63 63
 
64
-   /**
65
-    * @var string
66
-    */
64
+    /**
65
+     * @var string
66
+     */
67 67
     protected $csv = '';
68 68
     
69 69
     protected $data = array();
@@ -72,16 +72,16 @@  discard block
 block discarded – undo
72 72
     
73 73
     protected $headersPosition = self::HEADERS_NONE;
74 74
     
75
-   /**
76
-    * Loads CSV data from a string. 
77
-    * 
78
-    * Note: Use the {@link hasErrors()} method to 
79
-    * check if the string could be parsed correctly
80
-    * afterwards.
81
-    * 
82
-    * @param string $string
83
-    * @return CSVHelper
84
-    */
75
+    /**
76
+     * Loads CSV data from a string. 
77
+     * 
78
+     * Note: Use the {@link hasErrors()} method to 
79
+     * check if the string could be parsed correctly
80
+     * afterwards.
81
+     * 
82
+     * @param string $string
83
+     * @return CSVHelper
84
+     */
85 85
     public function loadString($string)
86 86
     {
87 87
         // remove any UTF byte order marks that may still be present in the string
@@ -95,20 +95,20 @@  discard block
 block discarded – undo
95 95
         return $this;
96 96
     }
97 97
     
98
-   /**
99
-    * Loads CSV data from a file.
100
-    * 
101
-    * Note: Use the {@link hasErrors()} method to 
102
-    * check if the string could be parsed correctly
103
-    * afterwards.
104
-    * 
105
-    * @param string $file
106
-    * @throws FileHelper_Exception
107
-    * @return CSVHelper
108
-    * 
109
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
110
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
111
-    */
98
+    /**
99
+     * Loads CSV data from a file.
100
+     * 
101
+     * Note: Use the {@link hasErrors()} method to 
102
+     * check if the string could be parsed correctly
103
+     * afterwards.
104
+     * 
105
+     * @param string $file
106
+     * @throws FileHelper_Exception
107
+     * @return CSVHelper
108
+     * 
109
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
110
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
111
+     */
112 112
     public function loadFile(string $file) : CSVHelper
113 113
     {
114 114
         $csv = FileHelper::readContents($file);
@@ -122,28 +122,28 @@  discard block
 block discarded – undo
122 122
     
123 123
     protected $rowCount = 0;
124 124
     
125
-   /**
126
-    * Specifies that headers are positioned on top, horizontally.
127
-    * @return CSVHelper
128
-    */
125
+    /**
126
+     * Specifies that headers are positioned on top, horizontally.
127
+     * @return CSVHelper
128
+     */
129 129
     public function setHeadersTop()
130 130
     {
131 131
         return $this->setHeadersPosition(self::HEADERS_TOP);
132 132
     }
133 133
     
134
-   /**
135
-    * Specifies that headers are positioned on the left, vertically.
136
-    * @return CSVHelper
137
-    */
134
+    /**
135
+     * Specifies that headers are positioned on the left, vertically.
136
+     * @return CSVHelper
137
+     */
138 138
     public function setHeadersLeft()
139 139
     {
140 140
         return $this->setHeadersPosition(self::HEADERS_LEFT);
141 141
     }
142 142
     
143
-   /**
144
-    * Specifies that there are no headers in the file (default).
145
-    * @return CSVHelper
146
-    */
143
+    /**
144
+     * Specifies that there are no headers in the file (default).
145
+     * @return CSVHelper
146
+     */
147 147
     public function setHeadersNone()
148 148
     {
149 149
         return $this->setHeadersPosition(self::HEADERS_NONE);
@@ -173,18 +173,18 @@  discard block
 block discarded – undo
173 173
         return false;
174 174
     }
175 175
     
176
-   /**
177
-    * Specifies where the headers are positioned in the
178
-    * CSV, or turns them off entirely. Use the class constants
179
-    * to ensure the value is correct.
180
-    * 
181
-    * @param string $position
182
-    * @throws CSVHelper_Exception
183
-    * @return CSVHelper
184
-    * @see CSVHelper::HEADERS_LEFT
185
-    * @see CSVHelper::HEADERS_TOP
186
-    * @see CSVHelper::HEADERS_NONE
187
-    */
176
+    /**
177
+     * Specifies where the headers are positioned in the
178
+     * CSV, or turns them off entirely. Use the class constants
179
+     * to ensure the value is correct.
180
+     * 
181
+     * @param string $position
182
+     * @throws CSVHelper_Exception
183
+     * @return CSVHelper
184
+     * @see CSVHelper::HEADERS_LEFT
185
+     * @see CSVHelper::HEADERS_TOP
186
+     * @see CSVHelper::HEADERS_NONE
187
+     */
188 188
     public function setHeadersPosition($position)
189 189
     {
190 190
         $validPositions = array(
@@ -211,13 +211,13 @@  discard block
 block discarded – undo
211 211
         return $this;
212 212
     }
213 213
     
214
-   /**
215
-    * Resets all internal data, allowing to start entirely anew
216
-    * with a new file, or to start building a new CSV file from
217
-    * scratch.
218
-    * 
219
-    * @return CSVHelper
220
-    */
214
+    /**
215
+     * Resets all internal data, allowing to start entirely anew
216
+     * with a new file, or to start building a new CSV file from
217
+     * scratch.
218
+     * 
219
+     * @return CSVHelper
220
+     */
221 221
     public function reset()
222 222
     {
223 223
         $this->data = array();
@@ -234,19 +234,19 @@  discard block
 block discarded – undo
234 234
         return $this->data;
235 235
     }
236 236
     
237
-   /**
238
-    * Retrieves the row at the specified index.
239
-    * If there is no data at the index, this will
240
-    * return an array populated with empty strings
241
-    * for all available columns.
242
-    * 
243
-    * Tip: Use the {@link rowExists()} method to check
244
-    * whether the specified row exists.
245
-    * 
246
-    * @param integer $index
247
-    * @return array()
248
-    * @see rowExists()
249
-    */
237
+    /**
238
+     * Retrieves the row at the specified index.
239
+     * If there is no data at the index, this will
240
+     * return an array populated with empty strings
241
+     * for all available columns.
242
+     * 
243
+     * Tip: Use the {@link rowExists()} method to check
244
+     * whether the specified row exists.
245
+     * 
246
+     * @param integer $index
247
+     * @return array()
248
+     * @see rowExists()
249
+     */
250 250
     public function getRow($index)
251 251
     {
252 252
         if(isset($this->data[$index])) {
@@ -256,63 +256,63 @@  discard block
 block discarded – undo
256 256
         return array_fill(0, $this->rowCount, '');
257 257
     }
258 258
     
259
-   /**
260
-    * Checks whether the specified row exists in the data set.
261
-    * @param integer $index
262
-    * @return boolean
263
-    */
259
+    /**
260
+     * Checks whether the specified row exists in the data set.
261
+     * @param integer $index
262
+     * @return boolean
263
+     */
264 264
     public function rowExists($index)
265 265
     {
266 266
         return isset($this->data[$index]);
267 267
     }
268 268
     
269
-   /**
270
-    * Counts the amount of rows in the parsed CSV,
271
-    * excluding the headers if any, depending on 
272
-    * their position.
273
-    * 
274
-    * @return integer
275
-    */
269
+    /**
270
+     * Counts the amount of rows in the parsed CSV,
271
+     * excluding the headers if any, depending on 
272
+     * their position.
273
+     * 
274
+     * @return integer
275
+     */
276 276
     public function countRows()
277 277
     {
278 278
         return $this->rowCount;
279 279
     }
280 280
     
281
-   /**
282
-    * Counts the amount of rows in the parsed CSV, 
283
-    * excluding the headers if any, depending on
284
-    * their position.
285
-    * 
286
-    * @return integer
287
-    */
281
+    /**
282
+     * Counts the amount of rows in the parsed CSV, 
283
+     * excluding the headers if any, depending on
284
+     * their position.
285
+     * 
286
+     * @return integer
287
+     */
288 288
     public function countColumns()
289 289
     {
290 290
         return $this->columnCount;
291 291
     }
292 292
     
293
-   /**
294
-    * Retrieves the headers, if any. Specify the position of the
295
-    * headers first to ensure this works correctly.
296
-    * 
297
-    * @return array Indexed array with header names.
298
-    */
293
+    /**
294
+     * Retrieves the headers, if any. Specify the position of the
295
+     * headers first to ensure this works correctly.
296
+     * 
297
+     * @return array Indexed array with header names.
298
+     */
299 299
     public function getHeaders()
300 300
     {
301 301
         return $this->headers;
302 302
     }
303 303
     
304
-   /**
305
-    * Retrieves the column at the specified index. If there
306
-    * is no column at the index, this returns an array
307
-    * populated with empty strings.
308
-    * 
309
-    * Tip: Use the {@link columnExists()} method to check
310
-    * whether a column exists.
311
-    * 
312
-    * @param integer $index
313
-    * @return string[]
314
-    * @see columnExists()
315
-    */
304
+    /**
305
+     * Retrieves the column at the specified index. If there
306
+     * is no column at the index, this returns an array
307
+     * populated with empty strings.
308
+     * 
309
+     * Tip: Use the {@link columnExists()} method to check
310
+     * whether a column exists.
311
+     * 
312
+     * @param integer $index
313
+     * @return string[]
314
+     * @see columnExists()
315
+     */
316 316
     public function getColumn($index)
317 317
     {
318 318
         $data = array();
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
         return $data;
329 329
     }
330 330
     
331
-   /**
332
-    * Checks whether the specified column exists in the data set.
333
-    * @param integer $index
334
-    * @return boolean
335
-    */
331
+    /**
332
+     * Checks whether the specified column exists in the data set.
333
+     * @param integer $index
334
+     * @return boolean
335
+     */
336 336
     public function columnExists($index)
337 337
     {
338 338
         if($index < $this->columnCount) {
@@ -396,22 +396,22 @@  discard block
 block discarded – undo
396 396
         }
397 397
     }
398 398
     
399
-   /**
400
-    * Checks whether any errors have been encountered
401
-    * while parsing the CSV.
402
-    * 
403
-    * @return boolean
404
-    * @see getErrorMessages()
405
-    */
399
+    /**
400
+     * Checks whether any errors have been encountered
401
+     * while parsing the CSV.
402
+     * 
403
+     * @return boolean
404
+     * @see getErrorMessages()
405
+     */
406 406
     public function hasErrors()
407 407
     {
408 408
         return !empty($this->errors);
409 409
     }
410 410
     
411
-   /**
412
-    * Retrieves all error messages.
413
-    * @return array
414
-    */
411
+    /**
412
+     * Retrieves all error messages.
413
+     * @return array
414
+     */
415 415
     public function getErrorMessages()
416 416
     {
417 417
         return $this->errors;
Please login to merge, or discard this patch.
src/ConvertHelper/ThrowableInfo.php 1 patch
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -14,49 +14,49 @@  discard block
 block discarded – undo
14 14
     const CONTEXT_COMMAND_LINE = 'cli';
15 15
     const CONTEXT_WEB = 'web';
16 16
     
17
-   /**
18
-    * @var \Throwable
19
-    */
17
+    /**
18
+     * @var \Throwable
19
+     */
20 20
     protected $exception;
21 21
     
22
-   /**
23
-    * @var ConvertHelper_ThrowableInfo_Call[]
24
-    */
22
+    /**
23
+     * @var ConvertHelper_ThrowableInfo_Call[]
24
+     */
25 25
     protected $calls = array();
26 26
     
27
-   /**
28
-    * @var integer
29
-    */
27
+    /**
28
+     * @var integer
29
+     */
30 30
     protected $code;
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $message;
36 36
     
37
-   /**
38
-    * @var integer
39
-    */
37
+    /**
38
+     * @var integer
39
+     */
40 40
     protected $callsCount = 0;
41 41
     
42
-   /**
43
-    * @var ConvertHelper_ThrowableInfo
44
-    */
42
+    /**
43
+     * @var ConvertHelper_ThrowableInfo
44
+     */
45 45
     protected $previous;
46 46
     
47
-   /**
48
-    * @var string
49
-    */
47
+    /**
48
+     * @var string
49
+     */
50 50
     protected $referer = '';
51 51
     
52
-   /**
53
-    * @var \DateTime
54
-    */
52
+    /**
53
+     * @var \DateTime
54
+     */
55 55
     protected $date;
56 56
     
57
-   /**
58
-    * @var string
59
-    */
57
+    /**
58
+     * @var string
59
+     */
60 60
     protected $context = self::CONTEXT_WEB;
61 61
     
62 62
     protected function __construct($subject)
@@ -103,16 +103,16 @@  discard block
 block discarded – undo
103 103
         return isset($this->previous);
104 104
     }
105 105
     
106
-   /**
107
-    * Retrieves the information on the previous exception.
108
-    * 
109
-    * NOTE: Throws an exception if there is no previous 
110
-    * exception. Use hasPrevious() first to avoid this.
111
-    * 
112
-    * @throws ConvertHelper_Exception
113
-    * @return ConvertHelper_ThrowableInfo
114
-    * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
115
-    */
106
+    /**
107
+     * Retrieves the information on the previous exception.
108
+     * 
109
+     * NOTE: Throws an exception if there is no previous 
110
+     * exception. Use hasPrevious() first to avoid this.
111
+     * 
112
+     * @throws ConvertHelper_Exception
113
+     * @return ConvertHelper_ThrowableInfo
114
+     * @see ConvertHelper_ThrowableInfo::ERROR_NO_PREVIOUS_EXCEPTION
115
+     */
116 116
     public function getPrevious() : ConvertHelper_ThrowableInfo
117 117
     {
118 118
         if(isset($this->previous)) {
@@ -131,9 +131,9 @@  discard block
 block discarded – undo
131 131
         return !empty($this->code);
132 132
     }
133 133
     
134
-   /**
135
-    * Improved textonly exception trace.
136
-    */
134
+    /**
135
+     * Improved textonly exception trace.
136
+     */
137 137
     public function toString() : string
138 138
     {
139 139
         $calls = $this->getCalls();
@@ -161,73 +161,73 @@  discard block
 block discarded – undo
161 161
         return $string;
162 162
     }
163 163
     
164
-   /**
165
-    * Retrieves the URL of the page in which the exception
166
-    * was thrown, if applicable: in CLI context, this will
167
-    * return an empty string.
168
-    * 
169
-    * @return string
170
-    */
164
+    /**
165
+     * Retrieves the URL of the page in which the exception
166
+     * was thrown, if applicable: in CLI context, this will
167
+     * return an empty string.
168
+     * 
169
+     * @return string
170
+     */
171 171
     public function getReferer() : string
172 172
     {
173 173
         return $this->referer;
174 174
     }
175 175
     
176
-   /**
177
-    * Whether the exception occurred in a command line context.
178
-    * @return bool
179
-    */
176
+    /**
177
+     * Whether the exception occurred in a command line context.
178
+     * @return bool
179
+     */
180 180
     public function isCommandLine() : bool
181 181
     {
182 182
         return $this->getContext() === self::CONTEXT_COMMAND_LINE;
183 183
     }
184 184
     
185
-   /**
186
-    * Whether the exception occurred during an http request.
187
-    * @return bool
188
-    */
185
+    /**
186
+     * Whether the exception occurred during an http request.
187
+     * @return bool
188
+     */
189 189
     public function isWebRequest() : bool
190 190
     {
191 191
         return $this->getContext() === self::CONTEXT_WEB;
192 192
     }
193 193
     
194
-   /**
195
-    * Retrieves the context identifier, i.e. if the exception
196
-    * occurred in a command line context or regular web request.
197
-    * 
198
-    * @return string
199
-    * 
200
-    * @see ConvertHelper_ThrowableInfo::isCommandLine()
201
-    * @see ConvertHelper_ThrowableInfo::isWebRequest()
202
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
203
-    * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
204
-    */
194
+    /**
195
+     * Retrieves the context identifier, i.e. if the exception
196
+     * occurred in a command line context or regular web request.
197
+     * 
198
+     * @return string
199
+     * 
200
+     * @see ConvertHelper_ThrowableInfo::isCommandLine()
201
+     * @see ConvertHelper_ThrowableInfo::isWebRequest()
202
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_COMMAND_LINE
203
+     * @see ConvertHelper_ThrowableInfo::CONTEXT_WEB
204
+     */
205 205
     public function getContext() : string
206 206
     {
207 207
         return $this->context;
208 208
     }
209 209
     
210
-   /**
211
-    * Retrieves the date of the exception, and approximate time:
212
-    * since exceptions do not store time, this is captured the 
213
-    * moment the ThrowableInfo is created.
214
-    * 
215
-    * @return \DateTime
216
-    */
210
+    /**
211
+     * Retrieves the date of the exception, and approximate time:
212
+     * since exceptions do not store time, this is captured the 
213
+     * moment the ThrowableInfo is created.
214
+     * 
215
+     * @return \DateTime
216
+     */
217 217
     public function getDate() : \DateTime
218 218
     {
219 219
         return $this->date;
220 220
     }
221 221
     
222
-   /**
223
-    * Serializes all information on the exception to an
224
-    * associative array. This can be saved (file, database, 
225
-    * session...), and later be restored into a throwable
226
-    * info instance using the fromSerialized() method.
227
-    * 
228
-    * @return array
229
-    * @see ConvertHelper_ThrowableInfo::fromSerialized()
230
-    */
222
+    /**
223
+     * Serializes all information on the exception to an
224
+     * associative array. This can be saved (file, database, 
225
+     * session...), and later be restored into a throwable
226
+     * info instance using the fromSerialized() method.
227
+     * 
228
+     * @return array
229
+     * @see ConvertHelper_ThrowableInfo::fromSerialized()
230
+     */
231 231
     public function serialize() : array
232 232
     {
233 233
         $result = array(
@@ -254,24 +254,24 @@  discard block
 block discarded – undo
254 254
         return $result;
255 255
     }
256 256
 
257
-   /**
258
-    * Sets the maximum folder depth to show in the 
259
-    * file paths, to avoid them being too long.
260
-    * 
261
-    * @param int $depth
262
-    * @return ConvertHelper_ThrowableInfo
263
-    */
257
+    /**
258
+     * Sets the maximum folder depth to show in the 
259
+     * file paths, to avoid them being too long.
260
+     * 
261
+     * @param int $depth
262
+     * @return ConvertHelper_ThrowableInfo
263
+     */
264 264
     public function setFolderDepth(int $depth) : ConvertHelper_ThrowableInfo
265 265
     {
266 266
         return $this->setOption('folder-depth', $depth);
267 267
     }
268 268
     
269
-   /**
270
-    * Retrieves the current folder depth option value.
271
-    * 
272
-    * @return int
273
-    * @see ConvertHelper_ThrowableInfo::setFolderDepth()
274
-    */
269
+    /**
270
+     * Retrieves the current folder depth option value.
271
+     * 
272
+     * @return int
273
+     * @see ConvertHelper_ThrowableInfo::setFolderDepth()
274
+     */
275 275
     public function getFolderDepth() : int
276 276
     {
277 277
         $depth = $this->getOption('folder-depth');
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
         return 2;
283 283
     }
284 284
     
285
-   /**
286
-    * Retrieves all function calls that led to the error.
287
-    * @return ConvertHelper_ThrowableInfo_Call[]
288
-    */
285
+    /**
286
+     * Retrieves all function calls that led to the error.
287
+     * @return ConvertHelper_ThrowableInfo_Call[]
288
+     */
289 289
     public function getCalls()
290 290
     {
291 291
         return $this->calls;
292 292
     }
293 293
     
294
-   /**
295
-    * Returns the amount of function and method calls in the stack trace.
296
-    * @return int
297
-    */
294
+    /**
295
+     * Returns the amount of function and method calls in the stack trace.
296
+     * @return int
297
+     */
298 298
     public function countCalls() : int
299 299
     {
300 300
         return $this->callsCount;
Please login to merge, or discard this patch.
src/ConvertHelper/EOL.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
     const TYPE_LF = 'LF';
30 30
     const TYPE_CR = 'CR';
31 31
     
32
-   /**
33
-    * @var string
34
-    */
32
+    /**
33
+     * @var string
34
+     */
35 35
     protected $char;
36 36
     
37
-   /**
38
-    * @var string
39
-    */
37
+    /**
38
+     * @var string
39
+     */
40 40
     protected $type;
41 41
     
42
-   /**
43
-    * @var string
44
-    */
42
+    /**
43
+     * @var string
44
+     */
45 45
     protected $description;
46 46
     
47 47
     public function __construct(string $char, string $type, string $description)
@@ -51,33 +51,33 @@  discard block
 block discarded – undo
51 51
         $this->description = $description;
52 52
     }
53 53
     
54
-   /**
55
-    * The actual EOL character.
56
-    * @return string
57
-    */
54
+    /**
55
+     * The actual EOL character.
56
+     * @return string
57
+     */
58 58
     public function getCharacter() : string
59 59
     {
60 60
         return $this->char;
61 61
     }
62 62
     
63
-   /**
64
-    * A more detailed, human readable description of the character.
65
-    * @return string
66
-    */
63
+    /**
64
+     * A more detailed, human readable description of the character.
65
+     * @return string
66
+     */
67 67
     public function getDescription() : string
68 68
     {
69 69
         return $this->description;
70 70
     }
71 71
     
72
-   /**
73
-    * The EOL character type, e.g. "CR+LF", "CR"...
74
-    * @return string
75
-    * 
76
-    * @see ConvertHelper_EOL::TYPE_CR
77
-    * @see ConvertHelper_EOL::TYPE_CRLF
78
-    * @see ConvertHelper_EOL::TYPE_LF
79
-    * @see ConvertHelper_EOL::TYPE_LFCR
80
-    */
72
+    /**
73
+     * The EOL character type, e.g. "CR+LF", "CR"...
74
+     * @return string
75
+     * 
76
+     * @see ConvertHelper_EOL::TYPE_CR
77
+     * @see ConvertHelper_EOL::TYPE_CRLF
78
+     * @see ConvertHelper_EOL::TYPE_LF
79
+     * @see ConvertHelper_EOL::TYPE_LFCR
80
+     */
81 81
     public function getType() : string
82 82
     {
83 83
         return $this->type;
Please login to merge, or discard this patch.
src/FileHelper/FileFinder.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,9 +31,9 @@
 block discarded – undo
31 31
     
32 32
     const PATH_MODE_STRIP = 'strip';
33 33
     
34
-   /**
35
-    * @var string
36
-    */
34
+    /**
35
+     * @var string
36
+     */
37 37
     protected $path;
38 38
     
39 39
     public function __construct(string $path)
Please login to merge, or discard this patch.
src/IniHelper.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -60,23 +60,23 @@  discard block
 block discarded – undo
60 60
         }
61 61
     }
62 62
     
63
-   /**
64
-    * The end of line character used in the INI source string.
65
-    * @return string
66
-    */
63
+    /**
64
+     * The end of line character used in the INI source string.
65
+     * @return string
66
+     */
67 67
     public function getEOLChar() : string
68 68
     {
69 69
         return $this->eol;
70 70
     }
71 71
     
72
-   /**
73
-    * Factory method: creates a new helper instance loading the
74
-    * ini content from the specified file.
75
-    * 
76
-    * @param string $iniPath
77
-    * @throws IniHelper_Exception
78
-    * @return \AppUtils\IniHelper
79
-    */
72
+    /**
73
+     * Factory method: creates a new helper instance loading the
74
+     * ini content from the specified file.
75
+     * 
76
+     * @param string $iniPath
77
+     * @throws IniHelper_Exception
78
+     * @return \AppUtils\IniHelper
79
+     */
80 80
     public static function createFromFile(string $iniPath)
81 81
     {
82 82
         $iniPath = FileHelper::requireFileExists($iniPath);
@@ -96,35 +96,35 @@  discard block
 block discarded – undo
96 96
         );
97 97
     }
98 98
     
99
-   /**
100
-    * Factory method: Creates a new ini helper instance from an ini string.
101
-    * 
102
-    * @param string $iniContent
103
-    * @return \AppUtils\IniHelper
104
-    */
99
+    /**
100
+     * Factory method: Creates a new ini helper instance from an ini string.
101
+     * 
102
+     * @param string $iniContent
103
+     * @return \AppUtils\IniHelper
104
+     */
105 105
     public static function createFromString(string $iniContent)
106 106
     {
107 107
         return new IniHelper($iniContent);
108 108
     }
109 109
     
110
-   /**
111
-    * Factory method: Creates a new empty ini helper.
112
-    *  
113
-    * @return \AppUtils\IniHelper
114
-    */
110
+    /**
111
+     * Factory method: Creates a new empty ini helper.
112
+     *  
113
+     * @return \AppUtils\IniHelper
114
+     */
115 115
     public static function createNew()
116 116
     {
117 117
         return self::createFromString('');
118 118
     }
119 119
     
120
-   /**
121
-    * Adds a new data section, and returns the section instance.
122
-    * If a section with the name already exists, returns that
123
-    * section instead of creating a new one.
124
-    *  
125
-    * @param string $name
126
-    * @return IniHelper_Section
127
-    */
120
+    /**
121
+     * Adds a new data section, and returns the section instance.
122
+     * If a section with the name already exists, returns that
123
+     * section instead of creating a new one.
124
+     *  
125
+     * @param string $name
126
+     * @return IniHelper_Section
127
+     */
128 128
     public function addSection(string $name) : IniHelper_Section
129 129
     {
130 130
         if(!isset($this->sections[$name])) {
@@ -134,12 +134,12 @@  discard block
 block discarded – undo
134 134
         return $this->sections[$name];
135 135
     }
136 136
     
137
-   /**
138
-    * Retrieves a section by its name, if it exists.
139
-    * 
140
-    * @param string $name
141
-    * @return IniHelper_Section|NULL
142
-    */
137
+    /**
138
+     * Retrieves a section by its name, if it exists.
139
+     * 
140
+     * @param string $name
141
+     * @return IniHelper_Section|NULL
142
+     */
143 143
     public function getSection(string $name) : ?IniHelper_Section
144 144
     {
145 145
         if(isset($this->sections[$name])) {
@@ -149,11 +149,11 @@  discard block
 block discarded – undo
149 149
         return null;
150 150
     }
151 151
     
152
-   /**
153
-    * Gets the data from the INI file as an associative array.
154
-    * 
155
-    * @return array
156
-    */
152
+    /**
153
+     * Gets the data from the INI file as an associative array.
154
+     * 
155
+     * @return array
156
+     */
157 157
     public function toArray() : array
158 158
     {
159 159
         $result = array();
@@ -173,17 +173,17 @@  discard block
 block discarded – undo
173 173
         return $result;
174 174
     }
175 175
     
176
-   /**
177
-    * Saves the INI content to the target file.
178
-    * 
179
-    * @param string $filePath
180
-    * @return IniHelper
181
-    * @throws FileHelper_Exception
182
-    * 
183
-    * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
184
-    * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
185
-    * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
186
-    */
176
+    /**
177
+     * Saves the INI content to the target file.
178
+     * 
179
+     * @param string $filePath
180
+     * @return IniHelper
181
+     * @throws FileHelper_Exception
182
+     * 
183
+     * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
184
+     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
185
+     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
186
+     */
187 187
     public function saveToFile(string $filePath) : IniHelper
188 188
     {
189 189
         FileHelper::saveFile($filePath, $this->saveToString());
@@ -191,11 +191,11 @@  discard block
 block discarded – undo
191 191
         return $this;
192 192
     }
193 193
     
194
-   /**
195
-    * Returns the INI content as string.
196
-    * 
197
-    * @return string
198
-    */
194
+    /**
195
+     * Returns the INI content as string.
196
+     * 
197
+     * @return string
198
+     */
199 199
     public function saveToString() : string
200 200
     {
201 201
         $parts = array();
@@ -208,15 +208,15 @@  discard block
 block discarded – undo
208 208
         return implode($this->eol, $parts);
209 209
     }
210 210
     
211
-   /**
212
-    * Sets or adds the value of a setting in the INI content.
213
-    * If the setting does not exist, it is added. Otherwise,
214
-    * the existing value is overwritten.
215
-    * 
216
-    * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>.
217
-    * @param mixed $value
218
-    * @return IniHelper
219
-    */
211
+    /**
212
+     * Sets or adds the value of a setting in the INI content.
213
+     * If the setting does not exist, it is added. Otherwise,
214
+     * the existing value is overwritten.
215
+     * 
216
+     * @param string $path A variable path, either <code>varname</code> or <code>section.varname</code>.
217
+     * @param mixed $value
218
+     * @return IniHelper
219
+     */
220 220
     public function setValue(string $path, $value) : IniHelper
221 221
     {
222 222
         $path = $this->parsePath($path);
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
         return $this;
236 236
     }
237 237
     
238
-   /**
239
-    * Checks whether a section with the specified name exists.
240
-    * 
241
-    * @param string $name
242
-    * @return bool
243
-    */
238
+    /**
239
+     * Checks whether a section with the specified name exists.
240
+     * 
241
+     * @param string $name
242
+     * @return bool
243
+     */
244 244
     public function sectionExists(string $name) : bool
245 245
     {
246 246
         foreach($this->sections as $section) {
@@ -252,23 +252,23 @@  discard block
 block discarded – undo
252 252
         return false;
253 253
     }
254 254
     
255
-   /**
256
-    * Retrieves the default section, which is used to add
257
-    * values in the root of the document.
258
-    * 
259
-    * @return IniHelper_Section
260
-    */
255
+    /**
256
+     * Retrieves the default section, which is used to add
257
+     * values in the root of the document.
258
+     * 
259
+     * @return IniHelper_Section
260
+     */
261 261
     public function getDefaultSection() : IniHelper_Section
262 262
     {
263 263
         return $this->addSection(self::SECTION_DEFAULT);
264 264
     }
265 265
     
266
-   /**
267
-    * Retrieves all variable lines for the specified path.
268
-    * 
269
-    * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>.
270
-    * @return array|\AppUtils\IniHelper_Line[]
271
-    */
266
+    /**
267
+     * Retrieves all variable lines for the specified path.
268
+     * 
269
+     * @param string $path A variable path. Either <code>varname</code> or <code>section.varname</code>.
270
+     * @return array|\AppUtils\IniHelper_Line[]
271
+     */
272 272
     public function getLinesByVariable(string $path)
273 273
     {
274 274
         $path = $this->parsePath($path);
Please login to merge, or discard this patch.
src/VariableInfo.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,25 +32,25 @@  discard block
 block discarded – undo
32 32
         self::TYPE_CALLABLE => 'cf5e20'
33 33
     );
34 34
     
35
-   /**
36
-    * @var string
37
-    */
35
+    /**
36
+     * @var string
37
+     */
38 38
     protected $string;
39 39
     
40
-   /**
41
-    * @var mixed
42
-    */
40
+    /**
41
+     * @var mixed
42
+     */
43 43
     protected $value;
44 44
     
45
-   /**
46
-    * @var string
47
-    */
45
+    /**
46
+     * @var string
47
+     */
48 48
     protected $type;
49 49
     
50
-   /**
51
-    * @param mixed $value
52
-    * @param array|null $serialized
53
-    */
50
+    /**
51
+     * @param mixed $value
52
+     * @param array|null $serialized
53
+     */
54 54
     public function __construct($value, $serialized=null)
55 55
     {
56 56
         if(is_array($serialized))
@@ -63,26 +63,26 @@  discard block
 block discarded – undo
63 63
         }
64 64
     }
65 65
     
66
-   /**
67
-    * Creates a new variable info instance from a PHP variable
68
-    * of any type.
69
-    * 
70
-    * @param mixed $variable
71
-    * @return VariableInfo
72
-    */
66
+    /**
67
+     * Creates a new variable info instance from a PHP variable
68
+     * of any type.
69
+     * 
70
+     * @param mixed $variable
71
+     * @return VariableInfo
72
+     */
73 73
     public static function fromVariable($variable) : VariableInfo
74 74
     {
75 75
         return new VariableInfo($variable);
76 76
     }
77 77
     
78
-   /**
79
-    * Restores a variable info instance using a previously serialized
80
-    * array using the serialize() method.
81
-    * 
82
-    * @param array $serialized
83
-    * @return VariableInfo
84
-    * @see VariableInfo::serialize()
85
-    */
78
+    /**
79
+     * Restores a variable info instance using a previously serialized
80
+     * array using the serialize() method.
81
+     * 
82
+     * @param array $serialized
83
+     * @return VariableInfo
84
+     * @see VariableInfo::serialize()
85
+     */
86 86
     public static function fromSerialized(array $serialized) : VariableInfo
87 87
     {
88 88
         return new VariableInfo(null, $serialized);
@@ -108,12 +108,12 @@  discard block
 block discarded – undo
108 108
         $this->string = $this->_toString();
109 109
     }
110 110
     
111
-   /**
112
-    * The variable type - this is the same string that
113
-    * is returned by the PHP function `gettype`.
114
-    * 
115
-    * @return string
116
-    */
111
+    /**
112
+     * The variable type - this is the same string that
113
+     * is returned by the PHP function `gettype`.
114
+     * 
115
+     * @return string
116
+     */
117 117
     public function getType() : string
118 118
     {
119 119
         return $this->type;
@@ -127,13 +127,13 @@  discard block
 block discarded – undo
127 127
         );
128 128
     }
129 129
     
130
-   /**
131
-    * Whether to prepend the variable type before the value, 
132
-    * like the var_dump function. Example: <code>string "Some text"</code>.
133
-    * 
134
-    * @param bool $enable
135
-    * @return VariableInfo
136
-    */
130
+    /**
131
+     * Whether to prepend the variable type before the value, 
132
+     * like the var_dump function. Example: <code>string "Some text"</code>.
133
+     * 
134
+     * @param bool $enable
135
+     * @return VariableInfo
136
+     */
137 137
     public function enableType(bool $enable=true) : VariableInfo
138 138
     {
139 139
         return $this->setOption('prepend-type', $enable);
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
         return $converted;
204 204
     }
205 205
     
206
-   /**
207
-    * Converts an array to a string.
208
-    * @return string
209
-    * 
210
-    * @todo Create custom dump implementation, using VariableInfo instances.
211
-    */
206
+    /**
207
+     * Converts an array to a string.
208
+     * @return string
209
+     * 
210
+     * @todo Create custom dump implementation, using VariableInfo instances.
211
+     */
212 212
     protected function toString_array() : string
213 213
     {
214 214
         $result = json_encode($this->value, JSON_PRETTY_PRINT);
Please login to merge, or discard this patch.
src/Request/Param.php 1 patch
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -111,18 +111,18 @@  discard block
 block discarded – undo
111 111
         }
112 112
     }
113 113
     
114
-   /**
115
-    * Adds a callback as a validation method. The callback gets the
116
-    * value to validate as first parameter, and any additional 
117
-    * parameters passed here get appended to that.
118
-    * 
119
-    * The callback must return boolean true or false depending on
120
-    * whether the value is valid.
121
-    * 
122
-    * @param mixed $callback
123
-    * @param array $args
124
-    * @return Request_Param
125
-    */
114
+    /**
115
+     * Adds a callback as a validation method. The callback gets the
116
+     * value to validate as first parameter, and any additional 
117
+     * parameters passed here get appended to that.
118
+     * 
119
+     * The callback must return boolean true or false depending on
120
+     * whether the value is valid.
121
+     * 
122
+     * @param mixed $callback
123
+     * @param array $args
124
+     * @return Request_Param
125
+     */
126 126
     public function setCallback($callback, $args=array())
127 127
     {
128 128
         if(!is_callable($callback)) {
@@ -264,13 +264,13 @@  discard block
 block discarded – undo
264 264
     
265 265
     protected $valueType = self::VALUE_TYPE_STRING;
266 266
 
267
-   /**
268
-    * Sets the variable to contain a comma-separated list of integer IDs.
269
-    * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
270
-    * <code>145</code>.
271
-    * 
272
-    * @return Request_Param
273
-    */
267
+    /**
268
+     * Sets the variable to contain a comma-separated list of integer IDs.
269
+     * Example: <code>145,248,4556</code>. A single ID is also allowed, e.g.
270
+     * <code>145</code>.
271
+     * 
272
+     * @return Request_Param
273
+     */
274 274
     public function setIDList()
275 275
     {
276 276
         $this->valueType = self::VALUE_TYPE_ID_LIST;
@@ -279,13 +279,13 @@  discard block
 block discarded – undo
279 279
         return $this;
280 280
     }
281 281
     
282
-   /**
283
-    * Sets the variable to be an alias, as defined by the
284
-    * {@link RegexHelper::REGEX_ALIAS} regular expression.
285
-    * 
286
-    * @return Request_Param
287
-    * @see RegexHelper::REGEX_ALIAS
288
-    */
282
+    /**
283
+     * Sets the variable to be an alias, as defined by the
284
+     * {@link RegexHelper::REGEX_ALIAS} regular expression.
285
+     * 
286
+     * @return Request_Param
287
+     * @see RegexHelper::REGEX_ALIAS
288
+     */
289 289
     public function setAlias()
290 290
     {
291 291
         return $this->setRegex(RegexHelper::REGEX_ALIAS);
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
         return $this->setValidation(self::VALIDATION_TYPE_ALPHA);
327 327
     }
328 328
     
329
-   /**
330
-    * Sets the parameter value as a string containing lowercase
331
-    * and/or uppercase letters, as well as numbers.
332
-    * 
333
-    * @return Request_Param
334
-    */
329
+    /**
330
+     * Sets the parameter value as a string containing lowercase
331
+     * and/or uppercase letters, as well as numbers.
332
+     * 
333
+     * @return Request_Param
334
+     */
335 335
     public function setAlnum()
336 336
     {
337 337
         return $this->setValidation(self::VALIDATION_TYPE_ALNUM);   
@@ -359,17 +359,17 @@  discard block
 block discarded – undo
359 359
         return $this->setValidation(self::VALIDATION_TYPE_ENUM, $args);
360 360
     }
361 361
     
362
-   /**
363
-    * Only available for array values: the parameter must be
364
-    * an array value, and the array may only contain values 
365
-    * specified in the values array.
366
-    * 
367
-    * Submitted values that are not in the allowed list of
368
-    * values are stripped from the value.
369
-    *  
370
-    * @param array $values List of allowed values
371
-    * @return \AppUtils\Request_Param
372
-    */
362
+    /**
363
+     * Only available for array values: the parameter must be
364
+     * an array value, and the array may only contain values 
365
+     * specified in the values array.
366
+     * 
367
+     * Submitted values that are not in the allowed list of
368
+     * values are stripped from the value.
369
+     *  
370
+     * @param array $values List of allowed values
371
+     * @return \AppUtils\Request_Param
372
+     */
373 373
     public function setValuesList(array $values)
374 374
     {
375 375
         $this->setArray();
@@ -382,39 +382,39 @@  discard block
 block discarded – undo
382 382
         return $this->setValidation(self::VALIDATION_TYPE_ARRAY);
383 383
     }
384 384
     
385
-   /**
386
-    * Specifies that a JSON-encoded string is expected.
387
-    * 
388
-    * NOTE: Numbers or quoted strings are technically valid
389
-    * JSON, but are not accepted, because it is assumed
390
-    * at least an array or object are expected.
391
-    * 
392
-    * @return \AppUtils\Request_Param
393
-    */
385
+    /**
386
+     * Specifies that a JSON-encoded string is expected.
387
+     * 
388
+     * NOTE: Numbers or quoted strings are technically valid
389
+     * JSON, but are not accepted, because it is assumed
390
+     * at least an array or object are expected.
391
+     * 
392
+     * @return \AppUtils\Request_Param
393
+     */
394 394
     public function setJSON() : Request_Param
395 395
     {
396 396
         return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => true));
397 397
     }
398 398
     
399
-   /**
400
-    * Like {@link Request_Param::setJSON()}, but accepts
401
-    * only JSON objects. Arrays will not be accepted.
402
-    * 
403
-    * @return \AppUtils\Request_Param
404
-    */
399
+    /**
400
+     * Like {@link Request_Param::setJSON()}, but accepts
401
+     * only JSON objects. Arrays will not be accepted.
402
+     * 
403
+     * @return \AppUtils\Request_Param
404
+     */
405 405
     public function setJSONObject() : Request_Param
406 406
     {
407 407
         return $this->setValidation(self::VALIDATION_TYPE_JSON, array('arrays' => false));
408 408
     }
409 409
     
410
-   /**
411
-    * The parameter is a string boolean representation. This means
412
-    * it can be any of the following: "yes", "true", "no", "false".
413
-    * The value is automatically converted to a boolean when retrieving
414
-    * the parameter.
415
-    * 
416
-    * @return Request_Param
417
-    */
410
+    /**
411
+     * The parameter is a string boolean representation. This means
412
+     * it can be any of the following: "yes", "true", "no", "false".
413
+     * The value is automatically converted to a boolean when retrieving
414
+     * the parameter.
415
+     * 
416
+     * @return Request_Param
417
+     */
418 418
     public function setBoolean() : Request_Param
419 419
     {
420 420
         $this->addCallbackFilter(array($this, 'applyFilter_boolean'));
@@ -478,15 +478,15 @@  discard block
 block discarded – undo
478 478
         return $keep;
479 479
     }
480 480
     
481
-   /**
482
-    * Validates the request parameter as an MD5 string,
483
-    * so that only values resembling md5 values are accepted.
484
-    * 
485
-    * NOTE: This can only guarantee the format, not whether
486
-    * it is an actual valid hash of something.
487
-    * 
488
-    * @return \AppUtils\Request_Param
489
-    */
481
+    /**
482
+     * Validates the request parameter as an MD5 string,
483
+     * so that only values resembling md5 values are accepted.
484
+     * 
485
+     * NOTE: This can only guarantee the format, not whether
486
+     * it is an actual valid hash of something.
487
+     * 
488
+     * @return \AppUtils\Request_Param
489
+     */
490 490
     public function setMD5() : Request_Param
491 491
     {
492 492
         return $this->setRegex(RegexHelper::REGEX_MD5);
@@ -528,14 +528,14 @@  discard block
 block discarded – undo
528 528
         return $this;
529 529
     }
530 530
     
531
-   /**
532
-    * Retrieves the value of the request parameter,
533
-    * applying all filters (if any) and validation
534
-    * (if any).
535
-    * 
536
-    * @param mixed $default
537
-    * @return mixed
538
-    */
531
+    /**
532
+     * Retrieves the value of the request parameter,
533
+     * applying all filters (if any) and validation
534
+     * (if any).
535
+     * 
536
+     * @param mixed $default
537
+     * @return mixed
538
+     */
539 539
     public function get($default=null)
540 540
     {
541 541
         $value = $this->request->getParam($this->paramName);
@@ -565,12 +565,12 @@  discard block
 block discarded – undo
565 565
         return null;
566 566
     }
567 567
     
568
-   /**
569
-    * Validates the syntax of an URL, but not its actual validity. 
570
-    * 
571
-    * @param mixed $value
572
-    * @return string
573
-    */
568
+    /**
569
+     * Validates the syntax of an URL, but not its actual validity. 
570
+     * 
571
+     * @param mixed $value
572
+     * @return string
573
+     */
574 574
     protected function validate_url($value) : string
575 575
     {
576 576
         if(!is_string($value)) {
@@ -710,10 +710,10 @@  discard block
 block discarded – undo
710 710
         return null;
711 711
     }
712 712
     
713
-   /**
714
-    * Makes sure that the value is a JSON-encoded string.
715
-    * @param mixed $value
716
-    */
713
+    /**
714
+     * Makes sure that the value is a JSON-encoded string.
715
+     * @param mixed $value
716
+     */
717 717
     protected function validate_json($value) : string
718 718
     {
719 719
         if(!is_string($value)) {
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
         if($this->validationParams['arrays'] === false) 
731 731
         {
732 732
             if(is_object(json_decode($value))) {
733
-               return $value; 
733
+                return $value; 
734 734
             }
735 735
         } 
736 736
         else 
@@ -810,12 +810,12 @@  discard block
 block discarded – undo
810 810
         return $this;
811 811
     }
812 812
     
813
-   /**
814
-    * Adds a filter that trims whitespace from the request
815
-    * parameter using the PHP <code>trim</code> function.
816
-    * 
817
-    * @return \AppUtils\Request_Param
818
-    */
813
+    /**
814
+     * Adds a filter that trims whitespace from the request
815
+     * parameter using the PHP <code>trim</code> function.
816
+     * 
817
+     * @return \AppUtils\Request_Param
818
+     */
819 819
     public function addFilterTrim() : Request_Param
820 820
     {
821 821
         // to guarantee we only work with strings
@@ -824,13 +824,13 @@  discard block
 block discarded – undo
824 824
         return $this->addCallbackFilter('trim');
825 825
     }
826 826
 
827
-   /**
828
-    * Converts the value to a string, even if it is not
829
-    * a string value. Complex types like arrays and objects
830
-    * are converted to an empty string.
831
-    * 
832
-    * @return \AppUtils\Request_Param
833
-    */
827
+    /**
828
+     * Converts the value to a string, even if it is not
829
+     * a string value. Complex types like arrays and objects
830
+     * are converted to an empty string.
831
+     * 
832
+     * @return \AppUtils\Request_Param
833
+     */
834 834
     public function addStringFilter() : Request_Param
835 835
     {
836 836
         return $this->addCallbackFilter(array($this, 'applyFilter_string'));
@@ -880,12 +880,12 @@  discard block
 block discarded – undo
880 880
         return $this->addCallbackFilter('strip_tags', array($allowedTags));
881 881
     }
882 882
     
883
-   /**
884
-    * Adds a filter that strips all whitespace from the
885
-    * request parameter, from spaces to tabs and newlines.
886
-    * 
887
-    * @return \AppUtils\Request_Param
888
-    */
883
+    /**
884
+     * Adds a filter that strips all whitespace from the
885
+     * request parameter, from spaces to tabs and newlines.
886
+     * 
887
+     * @return \AppUtils\Request_Param
888
+     */
889 889
     public function addStripWhitespaceFilter() : Request_Param
890 890
     {
891 891
         // to ensure we only work with strings.
@@ -894,14 +894,14 @@  discard block
 block discarded – undo
894 894
         return $this->addCallbackFilter(array($this, 'applyFilter_stripWhitespace'));
895 895
     }   
896 896
     
897
-   /**
898
-    * Adds a filter that transforms comma separated values
899
-    * into an array of values.
900
-    * 
901
-    * @param bool $trimEntries Trim whitespace from each entry?
902
-    * @param bool $stripEmptyEntries Remove empty entries from the array?
903
-    * @return \AppUtils\Request_Param
904
-    */
897
+    /**
898
+     * Adds a filter that transforms comma separated values
899
+     * into an array of values.
900
+     * 
901
+     * @param bool $trimEntries Trim whitespace from each entry?
902
+     * @param bool $stripEmptyEntries Remove empty entries from the array?
903
+     * @return \AppUtils\Request_Param
904
+     */
905 905
     public function addCommaSeparatedFilter(bool $trimEntries=true, bool $stripEmptyEntries=true) : Request_Param
906 906
     {
907 907
         $this->setArray();
@@ -915,12 +915,12 @@  discard block
 block discarded – undo
915 915
         );
916 916
     }
917 917
     
918
-   /**
919
-    * Adds a filter that encodes all HTML special characters
920
-    * using the PHP <code>htmlspecialchars</code> function.
921
-    * 
922
-    * @return \AppUtils\Request_Param
923
-    */
918
+    /**
919
+     * Adds a filter that encodes all HTML special characters
920
+     * using the PHP <code>htmlspecialchars</code> function.
921
+     * 
922
+     * @return \AppUtils\Request_Param
923
+     */
924 924
     public function addHTMLSpecialcharsFilter() : Request_Param
925 925
     {
926 926
         return $this->addCallbackFilter('htmlspecialchars', array(ENT_QUOTES, 'UTF-8'));
@@ -933,14 +933,14 @@  discard block
 block discarded – undo
933 933
     
934 934
     protected $required = false;
935 935
     
936
-   /**
937
-    * Marks this request parameter as required. To use this feature,
938
-    * you have to call the request's {@link Request::validate()}
939
-    * method.
940
-    * 
941
-    * @return Request_Param
942
-    * @see Request::validate()
943
-    */
936
+    /**
937
+     * Marks this request parameter as required. To use this feature,
938
+     * you have to call the request's {@link Request::validate()}
939
+     * method.
940
+     * 
941
+     * @return Request_Param
942
+     * @see Request::validate()
943
+     */
944 944
     public function makeRequired() : Request_Param
945 945
     {
946 946
         $this->required = true;
Please login to merge, or discard this patch.
src/BaseException.php 1 patch
Indentation   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -20,17 +20,17 @@  discard block
 block discarded – undo
20 20
  */
21 21
 class BaseException extends \Exception
22 22
 {
23
-   /**
24
-    * @var string
25
-    */
23
+    /**
24
+     * @var string
25
+     */
26 26
     protected $details;
27 27
     
28
-   /**
29
-    * @param string $message
30
-    * @param string $details
31
-    * @param int $code
32
-    * @param \Exception $previous
33
-    */
28
+    /**
29
+     * @param string $message
30
+     * @param string $details
31
+     * @param int $code
32
+     * @param \Exception $previous
33
+     */
34 34
     public function __construct(string $message, $details=null, $code=null, $previous=null)
35 35
     {
36 36
         parent::__construct($message, $code, $previous);
@@ -38,10 +38,10 @@  discard block
 block discarded – undo
38 38
         $this->details = $details;
39 39
     }
40 40
     
41
-   /**
42
-    * Retrieves the detailed error description, if any.
43
-    * @return string
44
-    */
41
+    /**
42
+     * Retrieves the detailed error description, if any.
43
+     * @return string
44
+     */
45 45
     public function getDetails() : string
46 46
     {
47 47
         if($this->details !== null) {
@@ -51,9 +51,9 @@  discard block
 block discarded – undo
51 51
         return '';
52 52
     }
53 53
     
54
-   /**
55
-    * Displays pertinent information on the exception.
56
-    */
54
+    /**
55
+     * Displays pertinent information on the exception.
56
+     */
57 57
     public function display()
58 58
     {
59 59
         if(!headers_sent()) {
@@ -63,20 +63,20 @@  discard block
 block discarded – undo
63 63
         echo $this->getInfo();
64 64
     }
65 65
     
66
-   /**
67
-    * Retrieves information on the exception that can be
68
-    * easily accessed.
69
-    * 
70
-    * @return ConvertHelper_ThrowableInfo
71
-    */
66
+    /**
67
+     * Retrieves information on the exception that can be
68
+     * easily accessed.
69
+     * 
70
+     * @return ConvertHelper_ThrowableInfo
71
+     */
72 72
     public function getInfo() : ConvertHelper_ThrowableInfo
73 73
     {
74 74
         return ConvertHelper::throwable2info($this);
75 75
     }
76 76
     
77
-   /**
78
-    * Dumps a current PHP function trace, as a textonly string.
79
-    */
77
+    /**
78
+     * Dumps a current PHP function trace, as a textonly string.
79
+     */
80 80
     public static function dumpTraceAsString()
81 81
     {
82 82
         try
@@ -89,9 +89,9 @@  discard block
 block discarded – undo
89 89
         }
90 90
     }
91 91
 
92
-   /**
93
-    * Dumps a current PHP function trace, with HTML styling.
94
-    */
92
+    /**
93
+     * Dumps a current PHP function trace, with HTML styling.
94
+     */
95 95
     public static function dumpTraceAsHTML()
96 96
     {
97 97
         try
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
         }
107 107
     }
108 108
     
109
-   /**
110
-    * Creates an exception info instance from a throwable instance.
111
-    * 
112
-    * @param \Throwable $e
113
-    * @return ConvertHelper_ThrowableInfo
114
-    * @see ConvertHelper::throwable2info()
115
-    */
109
+    /**
110
+     * Creates an exception info instance from a throwable instance.
111
+     * 
112
+     * @param \Throwable $e
113
+     * @return ConvertHelper_ThrowableInfo
114
+     * @see ConvertHelper::throwable2info()
115
+     */
116 116
     public static function createInfo(\Throwable $e) : ConvertHelper_ThrowableInfo
117 117
     {
118 118
         return ConvertHelper::throwable2info($e);
Please login to merge, or discard this patch.
src/FileHelper.php 1 patch
Indentation   +387 added lines, -387 removed lines patch added patch discarded remove patch
@@ -80,32 +80,32 @@  discard block
 block discarded – undo
80 80
     
81 81
     const ERROR_CANNOT_OPEN_FILE_TO_DETECT_BOM = 340032;
82 82
     
83
-   /**
84
-    * Opens a serialized file and returns the unserialized data.
85
-    * 
86
-    * @param string $file
87
-    * @throws FileHelper_Exception
88
-    * @return array
89
-    * @deprecated Use parseSerializedFile() instead.
90
-    * @see FileHelper::parseSerializedFile()
91
-    */
83
+    /**
84
+     * Opens a serialized file and returns the unserialized data.
85
+     * 
86
+     * @param string $file
87
+     * @throws FileHelper_Exception
88
+     * @return array
89
+     * @deprecated Use parseSerializedFile() instead.
90
+     * @see FileHelper::parseSerializedFile()
91
+     */
92 92
     public static function openUnserialized(string $file) : array
93 93
     {
94 94
         return self::parseSerializedFile($file);
95 95
     }
96 96
 
97
-   /**
98
-    * Opens a serialized file and returns the unserialized data.
99
-    *
100
-    * @param string $file
101
-    * @throws FileHelper_Exception
102
-    * @return array
103
-    * @see FileHelper::parseSerializedFile()
104
-    * 
105
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
106
-    * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
107
-    * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
108
-    */
97
+    /**
98
+     * Opens a serialized file and returns the unserialized data.
99
+     *
100
+     * @param string $file
101
+     * @throws FileHelper_Exception
102
+     * @return array
103
+     * @see FileHelper::parseSerializedFile()
104
+     * 
105
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
106
+     * @see FileHelper::ERROR_SERIALIZED_FILE_CANNOT_BE_READ
107
+     * @see FileHelper::ERROR_SERIALIZED_FILE_UNSERIALZE_FAILED
108
+     */
109 109
     public static function parseSerializedFile(string $file)
110 110
     {
111 111
         self::requireFileExists($file);
@@ -174,13 +174,13 @@  discard block
 block discarded – undo
174 174
         return rmdir($rootFolder);
175 175
     }
176 176
     
177
-   /**
178
-    * Create a folder, if it does not exist yet.
179
-    *  
180
-    * @param string $path
181
-    * @throws FileHelper_Exception
182
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
183
-    */
177
+    /**
178
+     * Create a folder, if it does not exist yet.
179
+     *  
180
+     * @param string $path
181
+     * @throws FileHelper_Exception
182
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
183
+     */
184 184
     public static function createFolder($path)
185 185
     {
186 186
         if(is_dir($path) || mkdir($path, 0777, true)) {
@@ -227,22 +227,22 @@  discard block
 block discarded – undo
227 227
         }
228 228
     }
229 229
     
230
-   /**
231
-    * Copies a file to the target location. Includes checks
232
-    * for most error sources, like the source file not being
233
-    * readable. Automatically creates the target folder if it
234
-    * does not exist yet.
235
-    * 
236
-    * @param string $sourcePath
237
-    * @param string $targetPath
238
-    * @throws FileHelper_Exception
239
-    * 
240
-    * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
241
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
242
-    * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
243
-    * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
244
-    * @see FileHelper::ERROR_CANNOT_COPY_FILE
245
-    */
230
+    /**
231
+     * Copies a file to the target location. Includes checks
232
+     * for most error sources, like the source file not being
233
+     * readable. Automatically creates the target folder if it
234
+     * does not exist yet.
235
+     * 
236
+     * @param string $sourcePath
237
+     * @param string $targetPath
238
+     * @throws FileHelper_Exception
239
+     * 
240
+     * @see FileHelper::ERROR_CANNOT_CREATE_FOLDER
241
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_FOUND
242
+     * @see FileHelper::ERROR_SOURCE_FILE_NOT_READABLE
243
+     * @see FileHelper::ERROR_TARGET_COPY_FOLDER_NOT_WRITABLE
244
+     * @see FileHelper::ERROR_CANNOT_COPY_FILE
245
+     */
246 246
     public static function copyFile($sourcePath, $targetPath)
247 247
     {
248 248
         self::requireFileExists($sourcePath, self::ERROR_SOURCE_FILE_NOT_FOUND);
@@ -293,15 +293,15 @@  discard block
 block discarded – undo
293 293
         );
294 294
     }
295 295
     
296
-   /**
297
-    * Deletes the target file. Ignored if it cannot be found,
298
-    * and throws an exception if it fails.
299
-    * 
300
-    * @param string $filePath
301
-    * @throws FileHelper_Exception
302
-    * 
303
-    * @see FileHelper::ERROR_CANNOT_DELETE_FILE
304
-    */
296
+    /**
297
+     * Deletes the target file. Ignored if it cannot be found,
298
+     * and throws an exception if it fails.
299
+     * 
300
+     * @param string $filePath
301
+     * @throws FileHelper_Exception
302
+     * 
303
+     * @see FileHelper::ERROR_CANNOT_DELETE_FILE
304
+     */
305 305
     public static function deleteFile(string $filePath) : void
306 306
     {
307 307
         if(!file_exists($filePath)) {
@@ -323,15 +323,15 @@  discard block
 block discarded – undo
323 323
     }
324 324
 
325 325
     /**
326
-    * Creates a new CSV parser instance and returns it.
327
-    * 
328
-    * @param string $delimiter
329
-    * @param string $enclosure
330
-    * @param string $escape
331
-    * @param bool $heading
332
-    * @return \parseCSV
333
-    * @todo Move this to the CSV helper.
334
-    */
326
+     * Creates a new CSV parser instance and returns it.
327
+     * 
328
+     * @param string $delimiter
329
+     * @param string $enclosure
330
+     * @param string $escape
331
+     * @param bool $heading
332
+     * @return \parseCSV
333
+     * @todo Move this to the CSV helper.
334
+     */
335 335
     public static function createCSVParser(string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : \parseCSV
336 336
     {
337 337
         if($delimiter==='') { $delimiter = ';'; }
@@ -346,23 +346,23 @@  discard block
 block discarded – undo
346 346
         return $parser;
347 347
     }
348 348
 
349
-   /**
350
-    * Parses all lines in the specified string and returns an
351
-    * indexed array with all csv values in each line.
352
-    *
353
-    * @param string $csv
354
-    * @param string $delimiter
355
-    * @param string $enclosure
356
-    * @param string $escape
357
-    * @param bool $heading
358
-    * @return array
359
-    * @throws FileHelper_Exception
360
-    * 
361
-    * @todo Move this to the CSVHelper.
362
-    *
363
-    * @see parseCSVFile()
364
-    * @see FileHelper::ERROR_PARSING_CSV
365
-    */
349
+    /**
350
+     * Parses all lines in the specified string and returns an
351
+     * indexed array with all csv values in each line.
352
+     *
353
+     * @param string $csv
354
+     * @param string $delimiter
355
+     * @param string $enclosure
356
+     * @param string $escape
357
+     * @param bool $heading
358
+     * @return array
359
+     * @throws FileHelper_Exception
360
+     * 
361
+     * @todo Move this to the CSVHelper.
362
+     *
363
+     * @see parseCSVFile()
364
+     * @see FileHelper::ERROR_PARSING_CSV
365
+     */
366 366
     public static function parseCSVString(string $csv, string $delimiter = ';', string $enclosure = '"', string $escape = '\\', bool $heading=false) : array
367 367
     {
368 368
         $parser = self::createCSVParser($delimiter, $enclosure, $escape, $heading);
@@ -541,31 +541,31 @@  discard block
 block discarded – undo
541 541
         );
542 542
     }
543 543
     
544
-   /**
545
-    * Verifies whether the target file is a PHP file. The path
546
-    * to the file can be a path to a file as a string, or a 
547
-    * DirectoryIterator object instance.
548
-    * 
549
-    * @param string|\DirectoryIterator $pathOrDirIterator
550
-    * @return boolean
551
-    */
544
+    /**
545
+     * Verifies whether the target file is a PHP file. The path
546
+     * to the file can be a path to a file as a string, or a 
547
+     * DirectoryIterator object instance.
548
+     * 
549
+     * @param string|\DirectoryIterator $pathOrDirIterator
550
+     * @return boolean
551
+     */
552 552
     public static function isPHPFile($pathOrDirIterator)
553 553
     {
554
-    	if(self::getExtension($pathOrDirIterator) == 'php') {
555
-    		return true;
556
-    	}
554
+        if(self::getExtension($pathOrDirIterator) == 'php') {
555
+            return true;
556
+        }
557 557
     	
558
-    	return false;
558
+        return false;
559 559
     }
560 560
     
561
-   /**
562
-    * Retrieves the extension of the specified file. Can be a path
563
-    * to a file as a string, or a DirectoryIterator object instance.
564
-    * 
565
-    * @param string|\DirectoryIterator $pathOrDirIterator
566
-    * @param bool $lowercase
567
-    * @return string
568
-    */
561
+    /**
562
+     * Retrieves the extension of the specified file. Can be a path
563
+     * to a file as a string, or a DirectoryIterator object instance.
564
+     * 
565
+     * @param string|\DirectoryIterator $pathOrDirIterator
566
+     * @param bool $lowercase
567
+     * @return string
568
+     */
569 569
     public static function getExtension($pathOrDirIterator, bool $lowercase = true) : string
570 570
     {
571 571
         if($pathOrDirIterator instanceof \DirectoryIterator) {
@@ -576,51 +576,51 @@  discard block
 block discarded – undo
576 576
          
577 577
         $ext = pathinfo($filename, PATHINFO_EXTENSION);
578 578
         if($lowercase) {
579
-        	$ext = mb_strtolower($ext);
579
+            $ext = mb_strtolower($ext);
580 580
         }
581 581
         
582 582
         return $ext;
583 583
     }
584 584
     
585
-   /**
586
-    * Retrieves the file name from a path, with or without extension.
587
-    * The path to the file can be a string, or a DirectoryIterator object
588
-    * instance.
589
-    * 
590
-    * In case of folders, behaves like the pathinfo function: returns
591
-    * the name of the folder.
592
-    * 
593
-    * @param string|\DirectoryIterator $pathOrDirIterator
594
-    * @param bool $extension
595
-    * @return string
596
-    */
585
+    /**
586
+     * Retrieves the file name from a path, with or without extension.
587
+     * The path to the file can be a string, or a DirectoryIterator object
588
+     * instance.
589
+     * 
590
+     * In case of folders, behaves like the pathinfo function: returns
591
+     * the name of the folder.
592
+     * 
593
+     * @param string|\DirectoryIterator $pathOrDirIterator
594
+     * @param bool $extension
595
+     * @return string
596
+     */
597 597
     public static function getFilename($pathOrDirIterator, $extension = true)
598 598
     {
599 599
         $path = $pathOrDirIterator;
600
-    	if($pathOrDirIterator instanceof \DirectoryIterator) {
601
-    		$path = $pathOrDirIterator->getFilename();
602
-    	}
600
+        if($pathOrDirIterator instanceof \DirectoryIterator) {
601
+            $path = $pathOrDirIterator->getFilename();
602
+        }
603 603
     	
604
-    	$path = self::normalizePath($path);
604
+        $path = self::normalizePath($path);
605 605
     	
606
-    	if(!$extension) {
607
-    	    return pathinfo($path, PATHINFO_FILENAME);
608
-    	}
606
+        if(!$extension) {
607
+            return pathinfo($path, PATHINFO_FILENAME);
608
+        }
609 609
     	
610
-    	return pathinfo($path, PATHINFO_BASENAME); 
610
+        return pathinfo($path, PATHINFO_BASENAME); 
611 611
     }
612 612
    
613
-   /**
614
-    * Tries to read the contents of the target file and
615
-    * treat it as JSON to return the decoded JSON data.
616
-    * 
617
-    * @param string $file
618
-    * @throws FileHelper_Exception
619
-    * @return array
620
-    * 
621
-    * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
622
-    * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
623
-    */ 
613
+    /**
614
+     * Tries to read the contents of the target file and
615
+     * treat it as JSON to return the decoded JSON data.
616
+     * 
617
+     * @param string $file
618
+     * @throws FileHelper_Exception
619
+     * @return array
620
+     * 
621
+     * @see FileHelper::ERROR_CANNOT_FIND_JSON_FILE
622
+     * @see FileHelper::ERROR_CANNOT_DECODE_JSON_FILE
623
+     */ 
624 624
     public static function parseJSONFile(string $file, $targetEncoding=null, $sourceEncoding=null)
625 625
     {
626 626
         self::requireFileExists($file, self::ERROR_CANNOT_FIND_JSON_FILE);
@@ -656,16 +656,16 @@  discard block
 block discarded – undo
656 656
         return $json;
657 657
     }
658 658
     
659
-   /**
660
-    * Corrects common formatting mistakes when users enter
661
-    * file names, like too many spaces, dots and the like.
662
-    * 
663
-    * NOTE: if the file name contains a path, the path is
664
-    * stripped, leaving only the file name.
665
-    * 
666
-    * @param string $name
667
-    * @return string
668
-    */
659
+    /**
660
+     * Corrects common formatting mistakes when users enter
661
+     * file names, like too many spaces, dots and the like.
662
+     * 
663
+     * NOTE: if the file name contains a path, the path is
664
+     * stripped, leaving only the file name.
665
+     * 
666
+     * @param string $name
667
+     * @return string
668
+     */
669 669
     public static function fixFileName(string $name) : string
670 670
     {
671 671
         $name = trim($name);
@@ -695,60 +695,60 @@  discard block
 block discarded – undo
695 695
         return $name;
696 696
     }
697 697
     
698
-   /**
699
-    * Creates an instance of the file finder, which is an easier
700
-    * alternative to the other manual findFile methods, since all
701
-    * options can be set by chaining.
702
-    * 
703
-    * @param string $path
704
-    * @return FileHelper_FileFinder
705
-    */
698
+    /**
699
+     * Creates an instance of the file finder, which is an easier
700
+     * alternative to the other manual findFile methods, since all
701
+     * options can be set by chaining.
702
+     * 
703
+     * @param string $path
704
+     * @return FileHelper_FileFinder
705
+     */
706 706
     public static function createFileFinder(string $path) : FileHelper_FileFinder
707 707
     {
708 708
         return new FileHelper_FileFinder($path);
709 709
     }
710 710
     
711
-   /**
712
-    * Searches for all HTML files in the target folder.
713
-    * 
714
-    * @param string $targetFolder
715
-    * @param array $options
716
-    * @return array An indexed array with files.
717
-    * @see FileHelper::createFileFinder()
718
-    * 
719
-    * @todo Convert this to use the file finder.
720
-    */
711
+    /**
712
+     * Searches for all HTML files in the target folder.
713
+     * 
714
+     * @param string $targetFolder
715
+     * @param array $options
716
+     * @return array An indexed array with files.
717
+     * @see FileHelper::createFileFinder()
718
+     * 
719
+     * @todo Convert this to use the file finder.
720
+     */
721 721
     public static function findHTMLFiles(string $targetFolder, array $options=array()) : array
722 722
     {
723 723
         return self::findFiles($targetFolder, array('html'), $options);
724 724
     }
725 725
 
726
-   /**
727
-    * Searches for all PHP files in the target folder.
728
-    * 
729
-    * @param string $targetFolder
730
-    * @param array $options
731
-    * @return array An indexed array of PHP files.
732
-    * @see FileHelper::createFileFinder()
733
-    * 
734
-    * @todo Convert this to use the file finder.
735
-    */
726
+    /**
727
+     * Searches for all PHP files in the target folder.
728
+     * 
729
+     * @param string $targetFolder
730
+     * @param array $options
731
+     * @return array An indexed array of PHP files.
732
+     * @see FileHelper::createFileFinder()
733
+     * 
734
+     * @todo Convert this to use the file finder.
735
+     */
736 736
     public static function findPHPFiles(string $targetFolder, array $options=array()) : array
737 737
     {
738 738
         return self::findFiles($targetFolder, array('php'), $options);
739 739
     }
740 740
     
741
-   /**
742
-    * 
743
-    * @param string $targetFolder
744
-    * @param array $extensions
745
-    * @param array $options
746
-    * @param array $files
747
-    * @throws FileHelper_Exception
748
-    * @return array
749
-    * @see FileHelper::createFileFinder()
750
-    * @todo Convert this to use the file finder. 
751
-    */
741
+    /**
742
+     * 
743
+     * @param string $targetFolder
744
+     * @param array $extensions
745
+     * @param array $options
746
+     * @param array $files
747
+     * @throws FileHelper_Exception
748
+     * @return array
749
+     * @see FileHelper::createFileFinder()
750
+     * @todo Convert this to use the file finder. 
751
+     */
752 752
     public static function findFiles(string $targetFolder, array $extensions=array(), array $options=array(), array $files=array()) : array
753 753
     {
754 754
         if(!isset($options['strip-extension'])) {
@@ -829,13 +829,13 @@  discard block
 block discarded – undo
829 829
         return $files;
830 830
     }
831 831
 
832
-   /**
833
-    * Removes the extension from the specified path or file name,
834
-    * if any, and returns the name without the extension.
835
-    * 
836
-    * @param string $filename
837
-    * @return sTring
838
-    */
832
+    /**
833
+     * Removes the extension from the specified path or file name,
834
+     * if any, and returns the name without the extension.
835
+     * 
836
+     * @param string $filename
837
+     * @return sTring
838
+     */
839 839
     public static function removeExtension(string $filename) : string
840 840
     {
841 841
         // normalize paths to allow windows style slashes even on nix servers
@@ -844,22 +844,22 @@  discard block
 block discarded – undo
844 844
         return pathinfo($filename, PATHINFO_FILENAME);
845 845
     }
846 846
     
847
-   /**
848
-    * Detects the UTF BOM in the target file, if any. Returns
849
-    * the encoding matching the BOM, which can be any of the
850
-    * following:
851
-    * 
852
-    * <ul>
853
-    * <li>UTF32-BE</li>
854
-    * <li>UTF32-LE</li>
855
-    * <li>UTF16-BE</li>
856
-    * <li>UTF16-LE</li>
857
-    * <li>UTF8</li>
858
-    * </ul>
859
-    * 
860
-    * @param string $filename
861
-    * @return string|NULL
862
-    */
847
+    /**
848
+     * Detects the UTF BOM in the target file, if any. Returns
849
+     * the encoding matching the BOM, which can be any of the
850
+     * following:
851
+     * 
852
+     * <ul>
853
+     * <li>UTF32-BE</li>
854
+     * <li>UTF32-LE</li>
855
+     * <li>UTF16-BE</li>
856
+     * <li>UTF16-LE</li>
857
+     * <li>UTF8</li>
858
+     * </ul>
859
+     * 
860
+     * @param string $filename
861
+     * @return string|NULL
862
+     */
863 863
     public static function detectUTFBom(string $filename) : ?string
864 864
     {
865 865
         $fp = fopen($filename, 'r');
@@ -891,13 +891,13 @@  discard block
 block discarded – undo
891 891
     
892 892
     protected static $utfBoms;
893 893
     
894
-   /**
895
-    * Retrieves a list of all UTF byte order mark character
896
-    * sequences, as an assocative array with UTF encoding => bom sequence
897
-    * pairs.
898
-    * 
899
-    * @return array
900
-    */
894
+    /**
895
+     * Retrieves a list of all UTF byte order mark character
896
+     * sequences, as an assocative array with UTF encoding => bom sequence
897
+     * pairs.
898
+     * 
899
+     * @return array
900
+     */
901 901
     public static function getUTFBOMs()
902 902
     {
903 903
         if(!isset(self::$utfBoms)) {
@@ -913,15 +913,15 @@  discard block
 block discarded – undo
913 913
         return self::$utfBoms;
914 914
     }
915 915
     
916
-   /**
917
-    * Checks whether the specified encoding is a valid
918
-    * unicode encoding, for example "UTF16-LE" or "UTF8".
919
-    * Also accounts for alternate way to write the, like
920
-    * "UTF-8", and omitting little/big endian suffixes.
921
-    * 
922
-    * @param string $encoding
923
-    * @return boolean
924
-    */
916
+    /**
917
+     * Checks whether the specified encoding is a valid
918
+     * unicode encoding, for example "UTF16-LE" or "UTF8".
919
+     * Also accounts for alternate way to write the, like
920
+     * "UTF-8", and omitting little/big endian suffixes.
921
+     * 
922
+     * @param string $encoding
923
+     * @return boolean
924
+     */
925 925
     public static function isValidUnicodeEncoding(string $encoding) : bool
926 926
     {
927 927
         $encodings = self::getKnownUnicodeEncodings();
@@ -940,22 +940,22 @@  discard block
 block discarded – undo
940 940
         return in_array($encoding, $keep);
941 941
     }
942 942
     
943
-   /**
944
-    * Retrieves a list of all known unicode file encodings.
945
-    * @return array
946
-    */
943
+    /**
944
+     * Retrieves a list of all known unicode file encodings.
945
+     * @return array
946
+     */
947 947
     public static function getKnownUnicodeEncodings()
948 948
     {
949 949
         return array_keys(self::getUTFBOMs());
950 950
     }
951 951
     
952
-   /**
953
-    * Normalizes the slash style in a file or folder path,
954
-    * by replacing any antislashes with forward slashes.
955
-    * 
956
-    * @param string $path
957
-    * @return string
958
-    */
952
+    /**
953
+     * Normalizes the slash style in a file or folder path,
954
+     * by replacing any antislashes with forward slashes.
955
+     * 
956
+     * @param string $path
957
+     * @return string
958
+     */
959 959
     public static function normalizePath(string $path) : string
960 960
     {
961 961
         return str_replace(array('\\', '//'), array('/', '/'), $path);
@@ -988,18 +988,18 @@  discard block
 block discarded – undo
988 988
         }
989 989
     }
990 990
    
991
-   /**
992
-    * Saves the specified content to the target file, creating
993
-    * the file and the folder as necessary.
994
-    * 
995
-    * @param string $filePath
996
-    * @param string $content
997
-    * @throws FileHelper_Exception
998
-    * 
999
-    * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
1000
-    * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
1001
-    * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
1002
-    */
991
+    /**
992
+     * Saves the specified content to the target file, creating
993
+     * the file and the folder as necessary.
994
+     * 
995
+     * @param string $filePath
996
+     * @param string $content
997
+     * @throws FileHelper_Exception
998
+     * 
999
+     * @see FileHelper::ERROR_SAVE_FOLDER_NOT_WRITABLE
1000
+     * @see FileHelper::ERROR_SAVE_FILE_NOT_WRITABLE
1001
+     * @see FileHelper::ERROR_SAVE_FILE_WRITE_FAILED
1002
+     */
1003 1003
     public static function saveFile(string $filePath, string $content='') : void
1004 1004
     {
1005 1005
         // target file already exists
@@ -1052,12 +1052,12 @@  discard block
 block discarded – undo
1052 1052
         );
1053 1053
     }
1054 1054
     
1055
-   /**
1056
-    * Checks whether it is possible to run PHP command 
1057
-    * line commands.
1058
-    * 
1059
-    * @return boolean
1060
-    */
1055
+    /**
1056
+     * Checks whether it is possible to run PHP command 
1057
+     * line commands.
1058
+     * 
1059
+     * @return boolean
1060
+     */
1061 1061
     public static function canMakePHPCalls() : bool
1062 1062
     {
1063 1063
         return self::cliCommandExists('php');
@@ -1132,16 +1132,16 @@  discard block
 block discarded – undo
1132 1132
         return $result;
1133 1133
     }
1134 1134
     
1135
-   /**
1136
-    * Validates a PHP file's syntax.
1137
-    * 
1138
-    * NOTE: This will fail silently if the PHP command line
1139
-    * is not available. Use {@link FileHelper::canMakePHPCalls()}
1140
-    * to check this beforehand as needed.
1141
-    * 
1142
-    * @param string $path
1143
-    * @return boolean|array A boolean true if the file is valid, an array with validation messages otherwise.
1144
-    */
1135
+    /**
1136
+     * Validates a PHP file's syntax.
1137
+     * 
1138
+     * NOTE: This will fail silently if the PHP command line
1139
+     * is not available. Use {@link FileHelper::canMakePHPCalls()}
1140
+     * to check this beforehand as needed.
1141
+     * 
1142
+     * @param string $path
1143
+     * @return boolean|array A boolean true if the file is valid, an array with validation messages otherwise.
1144
+     */
1145 1145
     public static function checkPHPFileSyntax($path)
1146 1146
     {
1147 1147
         if(!self::canMakePHPCalls()) {
@@ -1165,14 +1165,14 @@  discard block
 block discarded – undo
1165 1165
         return $output;
1166 1166
     }
1167 1167
     
1168
-   /**
1169
-    * Retrieves the last modified date for the specified file or folder.
1170
-    * 
1171
-    * Note: If the target does not exist, returns null. 
1172
-    * 
1173
-    * @param string $path
1174
-    * @return \DateTime|NULL
1175
-    */
1168
+    /**
1169
+     * Retrieves the last modified date for the specified file or folder.
1170
+     * 
1171
+     * Note: If the target does not exist, returns null. 
1172
+     * 
1173
+     * @param string $path
1174
+     * @return \DateTime|NULL
1175
+     */
1176 1176
     public static function getModifiedDate($path)
1177 1177
     {
1178 1178
         $time = filemtime($path);
@@ -1185,22 +1185,22 @@  discard block
 block discarded – undo
1185 1185
         return null; 
1186 1186
     }
1187 1187
     
1188
-   /**
1189
-    * Retrieves the names of all subfolders in the specified path.
1190
-    * 
1191
-    * Available options:
1192
-    * 
1193
-    * - recursive: true/false
1194
-    *   Whether to search for subfolders recursively. 
1195
-    *   
1196
-    * - absolute-paths: true/false
1197
-    *   Whether to return a list of absolute paths.
1198
-    * 
1199
-    * @param string $targetFolder
1200
-    * @param array $options
1201
-    * @throws FileHelper_Exception
1202
-    * @return string[]
1203
-    */
1188
+    /**
1189
+     * Retrieves the names of all subfolders in the specified path.
1190
+     * 
1191
+     * Available options:
1192
+     * 
1193
+     * - recursive: true/false
1194
+     *   Whether to search for subfolders recursively. 
1195
+     *   
1196
+     * - absolute-paths: true/false
1197
+     *   Whether to return a list of absolute paths.
1198
+     * 
1199
+     * @param string $targetFolder
1200
+     * @param array $options
1201
+     * @throws FileHelper_Exception
1202
+     * @return string[]
1203
+     */
1204 1204
     public static function getSubfolders($targetFolder, $options = array())
1205 1205
     {
1206 1206
         if(!is_dir($targetFolder)) 
@@ -1261,16 +1261,16 @@  discard block
 block discarded – undo
1261 1261
         return $result;
1262 1262
     }
1263 1263
 
1264
-   /**
1265
-    * Retrieves the maximum allowed upload file size, in bytes.
1266
-    * Takes into account the PHP ini settings <code>post_max_size</code>
1267
-    * and <code>upload_max_filesize</code>. Since these cannot
1268
-    * be modified at runtime, they are the hard limits for uploads.
1269
-    * 
1270
-    * NOTE: Based on binary values, where 1KB = 1024 Bytes.
1271
-    * 
1272
-    * @return int Will return <code>-1</code> if no limit.
1273
-    */
1264
+    /**
1265
+     * Retrieves the maximum allowed upload file size, in bytes.
1266
+     * Takes into account the PHP ini settings <code>post_max_size</code>
1267
+     * and <code>upload_max_filesize</code>. Since these cannot
1268
+     * be modified at runtime, they are the hard limits for uploads.
1269
+     * 
1270
+     * NOTE: Based on binary values, where 1KB = 1024 Bytes.
1271
+     * 
1272
+     * @return int Will return <code>-1</code> if no limit.
1273
+     */
1274 1274
     public static function getMaxUploadFilesize() : int
1275 1275
     {
1276 1276
         static $max_size = -1;
@@ -1307,16 +1307,16 @@  discard block
 block discarded – undo
1307 1307
         return round($size);
1308 1308
     }
1309 1309
    
1310
-   /**
1311
-    * Makes a path relative using a folder depth: will reduce the
1312
-    * length of the path so that only the amount of folders defined
1313
-    * in the <code>$depth</code> attribute are shown below the actual
1314
-    * folder or file in the path.
1315
-    *  
1316
-    * @param string  $path The absolute or relative path
1317
-    * @param int $depth The folder depth to reduce the path to
1318
-    * @return string
1319
-    */
1310
+    /**
1311
+     * Makes a path relative using a folder depth: will reduce the
1312
+     * length of the path so that only the amount of folders defined
1313
+     * in the <code>$depth</code> attribute are shown below the actual
1314
+     * folder or file in the path.
1315
+     *  
1316
+     * @param string  $path The absolute or relative path
1317
+     * @param int $depth The folder depth to reduce the path to
1318
+     * @return string
1319
+     */
1320 1320
     public static function relativizePathByDepth(string $path, int $depth=2) : string
1321 1321
     {
1322 1322
         $path = self::normalizePath($path);
@@ -1354,23 +1354,23 @@  discard block
 block discarded – undo
1354 1354
         return trim(implode('/', $tokens), '/');
1355 1355
     }
1356 1356
     
1357
-   /**
1358
-    * Makes the specified path relative to another path,
1359
-    * by removing one from the other if found. Also 
1360
-    * normalizes the path to use forward slashes. 
1361
-    * 
1362
-    * Example:
1363
-    * 
1364
-    * <pre>
1365
-    * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
1366
-    * </pre>
1367
-    * 
1368
-    * Result: <code>to/file.txt</code>
1369
-    * 
1370
-    * @param string $path
1371
-    * @param string $relativeTo
1372
-    * @return string
1373
-    */
1357
+    /**
1358
+     * Makes the specified path relative to another path,
1359
+     * by removing one from the other if found. Also 
1360
+     * normalizes the path to use forward slashes. 
1361
+     * 
1362
+     * Example:
1363
+     * 
1364
+     * <pre>
1365
+     * relativizePath('c:\some\folder\to\file.txt', 'c:\some\folder');
1366
+     * </pre>
1367
+     * 
1368
+     * Result: <code>to/file.txt</code>
1369
+     * 
1370
+     * @param string $path
1371
+     * @param string $relativeTo
1372
+     * @return string
1373
+     */
1374 1374
     public static function relativizePath(string $path, string $relativeTo) : string
1375 1375
     {
1376 1376
         $path = self::normalizePath($path);
@@ -1382,17 +1382,17 @@  discard block
 block discarded – undo
1382 1382
         return $relative;
1383 1383
     }
1384 1384
     
1385
-   /**
1386
-    * Checks that the target file exists, and throws an exception
1387
-    * if it does not. 
1388
-    * 
1389
-    * @param string $path
1390
-    * @param int|NULL $errorCode Optional custom error code
1391
-    * @throws FileHelper_Exception
1392
-    * @return string The real path to the file
1393
-    * 
1394
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1395
-    */
1385
+    /**
1386
+     * Checks that the target file exists, and throws an exception
1387
+     * if it does not. 
1388
+     * 
1389
+     * @param string $path
1390
+     * @param int|NULL $errorCode Optional custom error code
1391
+     * @throws FileHelper_Exception
1392
+     * @return string The real path to the file
1393
+     * 
1394
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1395
+     */
1396 1396
     public static function requireFileExists(string $path, $errorCode=null) : string
1397 1397
     {
1398 1398
         $result = realpath($path);
@@ -1411,18 +1411,18 @@  discard block
 block discarded – undo
1411 1411
         );
1412 1412
     }
1413 1413
     
1414
-   /**
1415
-    * Reads a specific line number from the target file and returns its
1416
-    * contents, if the file has such a line. Does so with little memory
1417
-    * usage, as the file is not read entirely into memory.
1418
-    * 
1419
-    * @param string $path
1420
-    * @param int $lineNumber Note: 1-based; the first line is number 1.
1421
-    * @return string|NULL Will return null if the requested line does not exist.
1422
-    * @throws FileHelper_Exception
1423
-    * 
1424
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1425
-    */
1414
+    /**
1415
+     * Reads a specific line number from the target file and returns its
1416
+     * contents, if the file has such a line. Does so with little memory
1417
+     * usage, as the file is not read entirely into memory.
1418
+     * 
1419
+     * @param string $path
1420
+     * @param int $lineNumber Note: 1-based; the first line is number 1.
1421
+     * @return string|NULL Will return null if the requested line does not exist.
1422
+     * @throws FileHelper_Exception
1423
+     * 
1424
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1425
+     */
1426 1426
     public static function getLineFromFile(string $path, int $lineNumber) : ?string
1427 1427
     {
1428 1428
         self::requireFileExists($path);
@@ -1438,19 +1438,19 @@  discard block
 block discarded – undo
1438 1438
         $file->seek($targetLine);
1439 1439
         
1440 1440
         if($file->key() !== $targetLine) {
1441
-             return null;
1441
+                return null;
1442 1442
         }
1443 1443
         
1444 1444
         return $file->current(); 
1445 1445
     }
1446 1446
     
1447
-   /**
1448
-    * Retrieves the total amount of lines in the file, without 
1449
-    * reading the whole file into memory.
1450
-    * 
1451
-    * @param string $path
1452
-    * @return int
1453
-    */
1447
+    /**
1448
+     * Retrieves the total amount of lines in the file, without 
1449
+     * reading the whole file into memory.
1450
+     * 
1451
+     * @param string $path
1452
+     * @return int
1453
+     */
1454 1454
     public static function countFileLines(string $path) : int
1455 1455
     {
1456 1456
         self::requireFileExists($path);
@@ -1480,26 +1480,26 @@  discard block
 block discarded – undo
1480 1480
         return $number+1;
1481 1481
     }
1482 1482
     
1483
-   /**
1484
-    * Parses the target file to detect any PHP classes contained
1485
-    * within, and retrieve information on them. Does not use the 
1486
-    * PHP reflection API.
1487
-    * 
1488
-    * @param string $filePath
1489
-    * @return FileHelper_PHPClassInfo
1490
-    */
1483
+    /**
1484
+     * Parses the target file to detect any PHP classes contained
1485
+     * within, and retrieve information on them. Does not use the 
1486
+     * PHP reflection API.
1487
+     * 
1488
+     * @param string $filePath
1489
+     * @return FileHelper_PHPClassInfo
1490
+     */
1491 1491
     public static function findPHPClasses(string $filePath) : FileHelper_PHPClassInfo
1492 1492
     {
1493 1493
         return new FileHelper_PHPClassInfo($filePath);
1494 1494
     }
1495 1495
     
1496
-   /**
1497
-    * Detects the end of line style used in the target file, if any.
1498
-    * Can be used with large files, because it only reads part of it.
1499
-    * 
1500
-    * @param string $filePath The path to the file.
1501
-    * @return NULL|ConvertHelper_EOL The end of line character information, or NULL if none is found.
1502
-    */
1496
+    /**
1497
+     * Detects the end of line style used in the target file, if any.
1498
+     * Can be used with large files, because it only reads part of it.
1499
+     * 
1500
+     * @param string $filePath The path to the file.
1501
+     * @return NULL|ConvertHelper_EOL The end of line character information, or NULL if none is found.
1502
+     */
1503 1503
     public static function detectEOLCharacter(string $filePath) : ?ConvertHelper_EOL
1504 1504
     {
1505 1505
         // 20 lines is enough to get a good picture of the newline style in the file.
@@ -1512,18 +1512,18 @@  discard block
 block discarded – undo
1512 1512
         return ConvertHelper::detectEOLCharacter($string);
1513 1513
     }
1514 1514
     
1515
-   /**
1516
-    * Reads the specified amount of lines from the target file.
1517
-    * Unicode BOM compatible: any byte order marker is stripped
1518
-    * from the resulting lines.
1519
-    * 
1520
-    * @param string $filePath
1521
-    * @param int $amount Set to 0 to read all lines.
1522
-    * @return array
1523
-    * 
1524
-    * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1525
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1526
-    */
1515
+    /**
1516
+     * Reads the specified amount of lines from the target file.
1517
+     * Unicode BOM compatible: any byte order marker is stripped
1518
+     * from the resulting lines.
1519
+     * 
1520
+     * @param string $filePath
1521
+     * @param int $amount Set to 0 to read all lines.
1522
+     * @return array
1523
+     * 
1524
+     * @see FileHelper::ERROR_CANNOT_OPEN_FILE_TO_READ_LINES
1525
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1526
+     */
1527 1527
     public static function readLines(string $filePath, int $amount=0) : array
1528 1528
     {
1529 1529
         self::requireFileExists($filePath);
@@ -1574,16 +1574,16 @@  discard block
 block discarded – undo
1574 1574
         return $result;
1575 1575
     }
1576 1576
     
1577
-   /**
1578
-    * Reads all content from a file.
1579
-    * 
1580
-    * @param string $filePath
1581
-    * @throws FileHelper_Exception
1582
-    * @return string
1583
-    * 
1584
-    * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1585
-    * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
1586
-    */
1577
+    /**
1578
+     * Reads all content from a file.
1579
+     * 
1580
+     * @param string $filePath
1581
+     * @throws FileHelper_Exception
1582
+     * @return string
1583
+     * 
1584
+     * @see FileHelper::ERROR_FILE_DOES_NOT_EXIST
1585
+     * @see FileHelper::ERROR_CANNOT_READ_FILE_CONTENTS
1586
+     */
1587 1587
     public static function readContents(string $filePath) : string
1588 1588
     {
1589 1589
         self::requireFileExists($filePath);
Please login to merge, or discard this patch.