Completed
Push — master ( 4d24a6...d4ace1 )
by Terry
01:46
created
bin/benchmark.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 
4
-require_once __DIR__ . '/../../../../vendor/autoload.php';
4
+require_once __DIR__.'/../../../../vendor/autoload.php';
5 5
 
6 6
 use function Terah\Assert\Assert;
7 7
 
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 echo "Benchmarking static Terah\\Assert";
15 15
 $start = microtime(true);
16 16
 
17
-for ( $i = 0 ; $i < 100000 ; $i++ )
17
+for ($i = 0; $i < 100000; $i++)
18 18
 {
19 19
     Assert::that(true)->true();
20 20
 }
21 21
 $time = microtime(true) - $start;
22
-echo "Taken: $time" . PHP_EOL;
22
+echo "Taken: $time".PHP_EOL;
23 23
 
24 24
 echo "Benchmarking new Terah\\Assert";
25 25
 $start = microtime(true);
26 26
 
27
-for ( $i = 0 ; $i < 100000 ; $i++ )
27
+for ($i = 0; $i < 100000; $i++)
28 28
 {
29 29
     Assert(true)->true();
30 30
 }
31 31
 $time = microtime(true) - $start;
32
-echo "Taken: $time" . PHP_EOL;
32
+echo "Taken: $time".PHP_EOL;
33 33
 
34 34
 echo "Benchmarking fluent Beberlei";
35 35
 $start = microtime(true);
36 36
 
37
-for ( $i = 0 ; $i < 100000 ; $i++ )
37
+for ($i = 0; $i < 100000; $i++)
38 38
 {
39 39
     Beberlei\that(true)->true();
40 40
 }
41 41
 $time = microtime(true) - $start;
42
-echo "Taken: $time" . PHP_EOL;
42
+echo "Taken: $time".PHP_EOL;
43 43
 
Please login to merge, or discard this patch.
src/ValidationFailedException.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
Please login to merge, or discard this patch.
src/Tester.php 3 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      * @param Closure  $test
43 43
      * @param string   $suiteName
44 44
      * @param string   $successMessage
45
-     * @param int|null $exceptionCode
45
+     * @param integer $exceptionCode
46 46
      * @param string   $exceptionClass
47 47
      * @return Suite
48 48
      * @throws AssertionFailedException
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
      * @param string   $testName
167 167
      * @param Closure  $test
168 168
      * @param string   $successMessage
169
-     * @param int|null $exceptionCode
169
+     * @param integer $exceptionCode
170 170
      * @param string   $exceptionClass
171 171
      * @return Suite
172 172
      * @throws AssertionFailedException
@@ -251,7 +251,7 @@  discard block
 block discarded – undo
251 251
      * @param string   $testName
252 252
      * @param Closure  $test
253 253
      * @param string   $successMessage
254
-     * @param int|null $exceptionCode
254
+     * @param integer $exceptionCode
255 255
      * @param string   $exceptionClass
256 256
      * @throws AssertionFailedException
257 257
      */
@@ -707,8 +707,8 @@  discard block
 block discarded – undo
707 707
     /**
708 708
      * Log messages to resource
709 709
      *
710
-     * @param mixed          $level    The level of the log message
711
-     * @param string|object  $message  If an object is passed it must implement __toString()
710
+     * @param string          $level    The level of the log message
711
+     * @param string  $message  If an object is passed it must implement __toString()
712 712
      * @param array          $context  Placeholders to be substituted in the message
713 713
      */
714 714
     public function log($level, $message, array $context=[])
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     }
785 785
 
786 786
     /**
787
-     * @return mixed|resource
787
+     * @return resource
788 788
      * @throws \Exception
789 789
      */
790 790
     protected function getResource()
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -132,8 +132,7 @@  discard block
 block discarded – undo
132 132
                 $this->getLogger()->info("[{$testName}] - Starting...");
133 133
                 $testCase->runTest($this);
134 134
                 $this->getLogger()->info("[{$testName}] - " . $testCase->getSuccessMessage());
135
-            }
136
-            catch ( \Exception $e )
135
+            } catch ( \Exception $e )
137 136
             {
138 137
                 $expectedCode       = $testCase->getExceptionCode();
139 138
                 $expectedClass      = $testCase->getExceptionType();
@@ -723,8 +722,7 @@  discard block
 block discarded – undo
723 722
         if ( is_callable($this->formatter) )
724 723
         {
725 724
             $message = $this->formatter->__invoke(static::$logLevels[$level][4], $message, $context);
726
-        }
727
-        else
725
+        } else
728 726
         {
729 727
             $message = $this->formatMessage($level, $message, $context);
730 728
         }
Please login to merge, or discard this patch.
Spacing   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
     protected static $currentSuite  = self::DEFAULT_SUITE;
13 13
 
14 14
     /** @var Suite[]  */
15
-    protected static $suites        = [];
15
+    protected static $suites        = [ ];
16 16
 
17 17
     /** @var Logger $logger */
18 18
     public static $logger           = null;
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
      * @param string $suiteName
30 30
      * @return Suite
31 31
      */
32
-    public static function suite(string $suiteName='') : Suite
32
+    public static function suite(string $suiteName = '') : Suite
33 33
     {
34 34
         $suiteName                  = $suiteName ?: static::$currentSuite;
35
-        static::$suites[$suiteName] = new Suite();
35
+        static::$suites[ $suiteName ] = new Suite();
36 36
 
37
-        return static::$suites[$suiteName];
37
+        return static::$suites[ $suiteName ];
38 38
     }
39 39
 
40 40
     /**
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      * @return Suite
48 48
      * @throws AssertionFailedException
49 49
      */
50
-    public static function test(string $testName, Closure $test, string $suiteName='', string $successMessage='', int $exceptionCode=0, string $exceptionClass='') : Suite
50
+    public static function test(string $testName, Closure $test, string $suiteName = '', string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '') : Suite
51 51
     {
52 52
         Assert::that($successMessage)->notEmpty();
53 53
         Assert::that($test)->isCallable();
@@ -61,17 +61,17 @@  discard block
 block discarded – undo
61 61
      * @param string $testName
62 62
      * @return array
63 63
      */
64
-    public static function run(string $suiteName='', string $testName='') : array
64
+    public static function run(string $suiteName = '', string $testName = '') : array
65 65
     {
66 66
         $totalFailed    = 0;
67 67
         $totalTests     = 0;
68 68
         $suites         = static::$suites;
69
-        if ( ! empty($suiteName) )
69
+        if ( ! empty($suiteName))
70 70
         {
71 71
             Assert::that($suites)->keyExists($suiteName, "The test suite ({$suiteName}) has not been loaded");
72
-            $suites         = [$suites[$suiteName]];
72
+            $suites = [ $suites[ $suiteName ] ];
73 73
         }
74
-        foreach ( $suites as $suite )
74
+        foreach ($suites as $suite)
75 75
         {
76 76
             $totalFailed    += $suite->run($testName);
77 77
             $totalTests     += $suite->totalTestsCount();
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public static function getLogger() : Logger
87 87
     {
88
-        if ( ! static::$logger )
88
+        if ( ! static::$logger)
89 89
         {
90 90
             static::$logger = new Logger();
91 91
         }
@@ -97,15 +97,15 @@  discard block
 block discarded – undo
97 97
      * @param string $suiteName
98 98
      * @return Suite
99 99
      */
100
-    protected static function getSuite(string $suiteName='') : Suite
100
+    protected static function getSuite(string $suiteName = '') : Suite
101 101
     {
102
-        $suiteName                  = $suiteName ?: static::$currentSuite;
103
-        if ( ! array_key_exists($suiteName, static::$suites) )
102
+        $suiteName = $suiteName ?: static::$currentSuite;
103
+        if ( ! array_key_exists($suiteName, static::$suites))
104 104
         {
105 105
             return static::suite($suiteName);
106 106
         }
107 107
 
108
-        return static::$suites[$suiteName];
108
+        return static::$suites[ $suiteName ];
109 109
     }
110 110
 
111 111
 
@@ -122,22 +122,22 @@  discard block
 block discarded – undo
122 122
 
123 123
         $className          = array_values(array_diff_key(get_declared_classes(), $declaredClasses));
124 124
 
125
-        $reflectionClass    = new \ReflectionClass($className[0]);
125
+        $reflectionClass    = new \ReflectionClass($className[ 0 ]);
126 126
         $publicMethods      = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
127 127
         $fullClassName      = $reflectionClass->getName();
128 128
         $className          = $reflectionClass->getShortName();
129 129
         $namespace          = $reflectionClass->getNamespaceName();
130 130
         $constructorParams  = '';
131
-        foreach ( $publicMethods as $method )
131
+        foreach ($publicMethods as $method)
132 132
         {
133
-            if ( $method->isConstructor() )
133
+            if ($method->isConstructor())
134 134
             {
135
-                $constructorParams  = static::getMethodParams($method);
135
+                $constructorParams = static::getMethodParams($method);
136 136
             }
137 137
         }
138 138
         $objectInit         = "new {$fullClassName}({$constructorParams})";
139
-        $output             = [];
140
-        $output[]           = <<<PHP
139
+        $output             = [ ];
140
+        $output[ ]           = <<<PHP
141 141
 <?php declare(strict_types=1);
142 142
 
143 143
 namespace {$namespace}\Test;
@@ -151,22 +151,22 @@  discard block
 block discarded – undo
151 151
     ->fixture('testSubject', {$objectInit})
152 152
 PHP;
153 153
 
154
-        foreach ( $publicMethods as $method )
154
+        foreach ($publicMethods as $method)
155 155
         {
156 156
             $methodName         = $method->getName();
157 157
             $methodParams       = static::getMethodParams($method);
158
-            $testName           = 'test' . ucfirst($methodName);
158
+            $testName           = 'test'.ucfirst($methodName);
159 159
             $successArgs        = static::getMethodArgs($method);
160 160
             $failArgs           = static::getMethodArgs($method, '    ');
161 161
             $returnVal          = static::getReturnVal($method);
162 162
             $methodSignature    = "\$suite->getFixture('testSubject')->{$methodName}({$methodParams})";
163 163
 
164
-            if ( $method->isStatic() )
164
+            if ($method->isStatic())
165 165
             {
166 166
                 $methodSignature = "{$className}::{$methodName}({$methodParams})";
167 167
             }
168 168
 
169
-            $output[] = <<<PHP
169
+            $output[ ] = <<<PHP
170 170
             
171 171
     ->test('{$testName}Success', function(Suite \$suite) {
172 172
 
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 
191 191
         }
192 192
 
193
-        $output[] = "    ;";
193
+        $output[ ] = "    ;";
194 194
 
195 195
         return static::createDirectoriesAndSaveFile($outputPath, implode("\n", $output));
196 196
     }
@@ -203,7 +203,7 @@  discard block
 block discarded – undo
203 203
      * @param int $dirMode
204 204
      * @return bool
205 205
      */
206
-    protected static function createDirectoriesAndSaveFile(string $filePath, $data, $flags=0, $dirMode=0755) : bool
206
+    protected static function createDirectoriesAndSaveFile(string $filePath, $data, $flags = 0, $dirMode = 0755) : bool
207 207
     {
208 208
         static::createParentDirectories($filePath, $dirMode);
209 209
         Assert::that(file_put_contents($filePath, $data, $flags))->notFalse("Failed to put contents in file ({$filePath})");
@@ -216,13 +216,13 @@  discard block
 block discarded – undo
216 216
      * @param int $mode
217 217
      * @return bool
218 218
      */
219
-    protected static function createParentDirectories(string $filePath, $mode=0755) : bool
219
+    protected static function createParentDirectories(string $filePath, $mode = 0755) : bool
220 220
     {
221
-        $directoryPath  = preg_match('/.*\//', $filePath);
221
+        $directoryPath = preg_match('/.*\//', $filePath);
222 222
         Assert::that($filePath)
223 223
             ->notEmpty("Failed to identify path ({$directoryPath}) to create")
224 224
             ->notEq(DIRECTORY_SEPARATOR, "Failed to identify path ({$directoryPath}) to create");
225
-        if ( file_exists($directoryPath) )
225
+        if (file_exists($directoryPath))
226 226
         {
227 227
             Assert::that(is_dir($directoryPath))->notFalse("Failed to create parent directories.. files exists and is not a directory({$directoryPath})");
228 228
 
@@ -240,10 +240,10 @@  discard block
 block discarded – undo
240 240
      */
241 241
     protected static function getMethodParams(\ReflectionMethod $method) : string
242 242
     {
243
-        $output = [];
244
-        foreach ( $method->getParameters() as $param )
243
+        $output = [ ];
244
+        foreach ($method->getParameters() as $param)
245 245
         {
246
-            $output[] = '$' . $param->getName();
246
+            $output[ ] = '$'.$param->getName();
247 247
         }
248 248
 
249 249
         return implode(', ', $output);
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
      * @param string $extraPadding
255 255
      * @return string
256 256
      */
257
-    protected static function getMethodArgs(\ReflectionMethod $method, string $extraPadding='') : string
257
+    protected static function getMethodArgs(\ReflectionMethod $method, string $extraPadding = '') : string
258 258
     {
259
-        $output     = [];
259
+        $output     = [ ];
260 260
         $params     = $method->getParameters();
261
-        foreach ( $params as $param )
261
+        foreach ($params as $param)
262 262
         {
263 263
             $type       = $param->hasType() ? $param->getType()->_toString() : '';
264
-            $paramDef   = str_pad('$' . $param->getName(), 32, ' ') . '= ';
265
-            $paramDef   .= static::getDefaultValue($type);
266
-            $output[]   = $paramDef . ';';
264
+            $paramDef   = str_pad('$'.$param->getName(), 32, ' ').'= ';
265
+            $paramDef .= static::getDefaultValue($type);
266
+            $output[ ]   = $paramDef.';';
267 267
         }
268 268
 
269 269
         return implode("\n        {$extraPadding}", $output);
@@ -286,9 +286,9 @@  discard block
 block discarded – undo
286 286
      * @param string $default
287 287
      * @return string
288 288
      */
289
-    protected static function getDefaultValue(string $type='', string $default='null') : string
289
+    protected static function getDefaultValue(string $type = '', string $default = 'null') : string
290 290
     {
291
-        $typeMap    = [
291
+        $typeMap = [
292 292
             'int'           => "0",
293 293
             'float'         => "0.0",
294 294
             'string'        => "''",
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
             'array'         => "[]",
298 298
         ];
299 299
 
300
-        return $typeMap[$type] ?? $default;
300
+        return $typeMap[ $type ] ?? $default;
301 301
     }
302 302
 }
303 303
 
@@ -305,10 +305,10 @@  discard block
 block discarded – undo
305 305
 class Suite
306 306
 {
307 307
     /** @var Test[] */
308
-    protected $tests        = [];
308
+    protected $tests        = [ ];
309 309
 
310 310
     /** @var mixed[] */
311
-    protected $fixtures     = [];
311
+    protected $fixtures     = [ ];
312 312
 
313 313
     /** @var Logger */
314 314
     protected $logger       = null;
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
      * @param string $filter
321 321
      * @return int
322 322
      */
323
-    public function run(string $filter='') : int
323
+    public function run(string $filter = '') : int
324 324
     {
325
-        foreach ( $this->tests as $test => $testCase )
325
+        foreach ($this->tests as $test => $testCase)
326 326
         {
327
-            $testName   = $testCase->getTestName();
328
-            if ( $filter && $test !== $filter )
327
+            $testName = $testCase->getTestName();
328
+            if ($filter && $test !== $filter)
329 329
             {
330 330
                 continue;
331 331
             }
@@ -333,36 +333,36 @@  discard block
 block discarded – undo
333 333
             {
334 334
                 $this->getLogger()->info("[{$testName}] - Starting...");
335 335
                 $testCase->runTest($this);
336
-                $this->getLogger()->info("[{$testName}] - " . $testCase->getSuccessMessage());
336
+                $this->getLogger()->info("[{$testName}] - ".$testCase->getSuccessMessage());
337 337
             }
338
-            catch ( \Exception $e )
338
+            catch (\Exception $e)
339 339
             {
340 340
                 $expectedCode       = $testCase->getExceptionCode();
341 341
                 $expectedClass      = $testCase->getExceptionType();
342 342
                 $code               = $e->getCode();
343 343
                 $exception          = get_class($e);
344
-                if ( ! $expectedClass &&  ! $expectedCode )
344
+                if ( ! $expectedClass && ! $expectedCode)
345 345
                 {
346
-                    $this->getLogger()->error($e->getMessage(), [compact('testName'), $e]);
346
+                    $this->getLogger()->error($e->getMessage(), [ compact('testName'), $e ]);
347 347
                     $this->failedCount++;
348 348
 
349 349
                     continue;
350 350
                 }
351
-                if ( $expectedCode && $expectedCode !== $code )
351
+                if ($expectedCode && $expectedCode !== $code)
352 352
                 {
353
-                    $this->getLogger()->error("Exception code({$code}) was expected to be ({$expectedCode})", [compact('testName'), $e]);
353
+                    $this->getLogger()->error("Exception code({$code}) was expected to be ({$expectedCode})", [ compact('testName'), $e ]);
354 354
                     $this->failedCount++;
355 355
                     
356 356
                     continue;
357 357
                 }
358
-                if ( $expectedClass && $expectedClass !== $exception )
358
+                if ($expectedClass && $expectedClass !== $exception)
359 359
                 {
360
-                    $this->getLogger()->error("Exception class({$exception}) was expected to be ({$expectedClass})", [compact('testName'), $e]);
360
+                    $this->getLogger()->error("Exception class({$exception}) was expected to be ({$expectedClass})", [ compact('testName'), $e ]);
361 361
                     $this->failedCount++;
362 362
                     
363 363
                     continue;
364 364
                 }
365
-                $this->getLogger()->info("[{$test}] - " . $testCase->getSuccessMessage());
365
+                $this->getLogger()->info("[{$test}] - ".$testCase->getSuccessMessage());
366 366
             }
367 367
         }
368 368
         
@@ -394,9 +394,9 @@  discard block
 block discarded – undo
394 394
      * @return Suite
395 395
      * @throws AssertionFailedException
396 396
      */
397
-    public function test(string $testName, Closure $test, string $successMessage='', int $exceptionCode=0, string $exceptionClass='') : Suite
397
+    public function test(string $testName, Closure $test, string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '') : Suite
398 398
     {
399
-        $this->tests[]  = new Test($testName, $test, $successMessage, $exceptionCode, $exceptionClass);
399
+        $this->tests[ ] = new Test($testName, $test, $successMessage, $exceptionCode, $exceptionClass);
400 400
 
401 401
         return $this;
402 402
     }
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
      */
409 409
     public function fixture(string $fixtureName, $value) : Suite
410 410
     {
411
-        $this->fixtures[$fixtureName]  = $value;
411
+        $this->fixtures[ $fixtureName ] = $value;
412 412
 
413 413
         return $this;
414 414
     }
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
     {
423 423
         Assert::that($this->fixtures)->keyExists($fixtureName, "The fixture ({$fixtureName}) does not exist.");
424 424
 
425
-        return $this->fixtures[$fixtureName];
425
+        return $this->fixtures[ $fixtureName ];
426 426
     }
427 427
 
428 428
 
@@ -442,7 +442,7 @@  discard block
 block discarded – undo
442 442
      */
443 443
     public function getLogger() : Logger
444 444
     {
445
-        if ( ! $this->logger )
445
+        if ( ! $this->logger)
446 446
         {
447 447
             $this->logger = new Logger();
448 448
         }
@@ -479,7 +479,7 @@  discard block
 block discarded – undo
479 479
      * @param string   $exceptionClass
480 480
      * @throws AssertionFailedException
481 481
      */
482
-    public function __construct(string $testName, Closure $test, string $successMessage='', int $exceptionCode=0, string $exceptionClass='')
482
+    public function __construct(string $testName, Closure $test, string $successMessage = '', int $exceptionCode = 0, string $exceptionClass = '')
483 483
     {
484 484
         $this->setTestName($testName);
485 485
         $this->setTest($test);
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
      */
515 515
     public function getSuccessMessage() : string
516 516
     {
517
-        if ( ! $this->successMessage )
517
+        if ( ! $this->successMessage)
518 518
         {
519 519
             return "Successfully run {$this->testName}";
520 520
         }
@@ -667,21 +667,21 @@  discard block
 block discarded – undo
667 667
     /**
668 668
      * @var array $logLevels List of supported levels
669 669
      */
670
-    static protected $logLevels       = [
671
-        self::EMERGENCY => [1, self::WHITE,       self::RED,      self::DEFAULT,  'EMERG'],
672
-        self::ALERT     => [2, self::WHITE,       self::YELLOW,   self::DEFAULT,  'ALERT'],
673
-        self::CRITICAL  => [3, self::RED,         self::DEFAULT,  self::BOLD ,    'CRIT'],
674
-        self::ERROR     => [4, self::RED,         self::DEFAULT,  self::DEFAULT,  'ERROR'],
675
-        self::WARNING   => [5, self::YELLOW,      self::DEFAULT,  self::DEFAULT,  'WARN'],
676
-        self::NOTICE    => [6, self::CYAN,        self::DEFAULT,  self::DEFAULT,  'NOTE'],
677
-        self::INFO      => [7, self::GREEN,       self::DEFAULT,  self::DEFAULT,  'INFO'],
678
-        self::DEBUG     => [8, self::LIGHT_GRAY,  self::DEFAULT,  self::DEFAULT,  'DEBUG'],
670
+    static protected $logLevels = [
671
+        self::EMERGENCY => [ 1, self::WHITE, self::RED, self::DEFAULT, 'EMERG' ],
672
+        self::ALERT     => [ 2, self::WHITE, self::YELLOW, self::DEFAULT, 'ALERT' ],
673
+        self::CRITICAL  => [ 3, self::RED, self::DEFAULT, self::BOLD, 'CRIT' ],
674
+        self::ERROR     => [ 4, self::RED, self::DEFAULT, self::DEFAULT, 'ERROR' ],
675
+        self::WARNING   => [ 5, self::YELLOW, self::DEFAULT, self::DEFAULT, 'WARN' ],
676
+        self::NOTICE    => [ 6, self::CYAN, self::DEFAULT, self::DEFAULT, 'NOTE' ],
677
+        self::INFO      => [ 7, self::GREEN, self::DEFAULT, self::DEFAULT, 'INFO' ],
678
+        self::DEBUG     => [ 8, self::LIGHT_GRAY, self::DEFAULT, self::DEFAULT, 'DEBUG' ],
679 679
     ];
680 680
 
681 681
     /**
682 682
      * @var array
683 683
      */
684
-    static protected $colours   = [
684
+    static protected $colours = [
685 685
         'fore' => [
686 686
             self::BLACK         => '0;30',
687 687
             self::DARK_GRAY     => '1;30',
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
             self::CYAN          => '46',
713 713
             self::LIGHT_GRAY    => '47',
714 714
         ],
715
-        self::BOLD => [],
715
+        self::BOLD => [ ],
716 716
     ];
717 717
 
718 718
     /**
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
      * @param bool   $gzipFile
723 723
      * @param bool   $addDate
724 724
      */
725
-    public function __construct($resource=STDOUT, string $level=self::INFO, bool $useLocking=false, bool $gzipFile=false, bool $addDate=true)
725
+    public function __construct($resource = STDOUT, string $level = self::INFO, bool $useLocking = false, bool $gzipFile = false, bool $addDate = true)
726 726
     {
727 727
         $this->resource     = $resource;
728 728
         $this->setLogLevel($level);
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
      * @param string $message
738 738
      * @param array $context
739 739
      */
740
-    public function emergency(string $message, array $context=[])
740
+    public function emergency(string $message, array $context = [ ])
741 741
     {
742 742
         $this->log(self::EMERGENCY, $message, $context);
743 743
     }
@@ -751,7 +751,7 @@  discard block
 block discarded – undo
751 751
      * @param string $message
752 752
      * @param array $context
753 753
      */
754
-    public function alert(string $message, array $context=[])
754
+    public function alert(string $message, array $context = [ ])
755 755
     {
756 756
         $this->log(self::ALERT, $message, $context);
757 757
     }
@@ -764,7 +764,7 @@  discard block
 block discarded – undo
764 764
      * @param string $message
765 765
      * @param array $context
766 766
      */
767
-    public function critical(string $message, array $context=[])
767
+    public function critical(string $message, array $context = [ ])
768 768
     {
769 769
         $this->log(self::CRITICAL, $message, $context);
770 770
     }
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
      * @param string $message
777 777
      * @param array $context
778 778
      */
779
-    public function error(string $message, array $context=[])
779
+    public function error(string $message, array $context = [ ])
780 780
     {
781 781
         $this->log(self::ERROR, $message, $context);
782 782
     }
@@ -790,7 +790,7 @@  discard block
 block discarded – undo
790 790
      * @param string $message
791 791
      * @param array $context
792 792
      */
793
-    public function warning(string $message, array $context=[])
793
+    public function warning(string $message, array $context = [ ])
794 794
     {
795 795
         $this->log(self::WARNING, $message, $context);
796 796
     }
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
      * @param string $message
802 802
      * @param array $context
803 803
      */
804
-    public function notice(string $message, array $context=[])
804
+    public function notice(string $message, array $context = [ ])
805 805
     {
806 806
         $this->log(self::NOTICE, $message, $context);
807 807
     }
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
      * @param string $message
815 815
      * @param array $context
816 816
      */
817
-    public function info(string $message, array $context=[])
817
+    public function info(string $message, array $context = [ ])
818 818
     {
819 819
         $this->log(self::INFO, $message, $context);
820 820
     }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
      * @param string $message
826 826
      * @param array $context
827 827
      */
828
-    public function debug(string $message, array $context=[])
828
+    public function debug(string $message, array $context = [ ])
829 829
     {
830 830
         $this->log(self::DEBUG, $message, $context);
831 831
     }
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
      */
837 837
     public function setLogFile($resource) : Logger
838 838
     {
839
-        $this->resource     = $resource;
839
+        $this->resource = $resource;
840 840
 
841 841
         return $this;
842 842
     }
@@ -848,23 +848,23 @@  discard block
 block discarded – undo
848 848
      * @param bool $bold
849 849
      * @return string
850 850
      */
851
-    public static function addColour(string $string, string $foregroundColor='', string $backgroundColor='', bool $bold=false) : string
851
+    public static function addColour(string $string, string $foregroundColor = '', string $backgroundColor = '', bool $bold = false) : string
852 852
     {
853 853
         // todo: support bold
854 854
         unset($bold);
855 855
         $coloredString = '';
856 856
         // Check if given foreground color found
857
-        if ( isset(static::$colours['fore'][$foregroundColor]) )
857
+        if (isset(static::$colours[ 'fore' ][ $foregroundColor ]))
858 858
         {
859
-            $coloredString .= "\033[" . static::$colours['fore'][$foregroundColor] . "m";
859
+            $coloredString .= "\033[".static::$colours[ 'fore' ][ $foregroundColor ]."m";
860 860
         }
861 861
         // Check if given background color found
862
-        if ( isset(static::$colours['back'][$backgroundColor]) )
862
+        if (isset(static::$colours[ 'back' ][ $backgroundColor ]))
863 863
         {
864
-            $coloredString .= "\033[" . static::$colours['back'][$backgroundColor] . "m";
864
+            $coloredString .= "\033[".static::$colours[ 'back' ][ $backgroundColor ]."m";
865 865
         }
866 866
         // Add string and end coloring
867
-        $coloredString .=  $string . "\033[0m";
867
+        $coloredString .= $string."\033[0m";
868 868
 
869 869
         return $coloredString;
870 870
     }
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
      * @param bool      $bold
877 877
      * @return string
878 878
      */
879
-    public function colourize(string $string, string $foregroundColor='', string $backgroundColor='', bool $bold=false) : string
879
+    public function colourize(string $string, string $foregroundColor = '', string $backgroundColor = '', bool $bold = false) : string
880 880
     {
881 881
         return static::addColour($string, $foregroundColor, $backgroundColor, $bold);
882 882
     }
@@ -887,11 +887,11 @@  discard block
 block discarded – undo
887 887
      */
888 888
     public function setLogLevel(string $level) : Logger
889 889
     {
890
-        if ( ! isset(static::$logLevels[$level]) )
890
+        if ( ! isset(static::$logLevels[ $level ]))
891 891
         {
892 892
             throw new \InvalidArgumentException("Log level is invalid");
893 893
         }
894
-        $this->level = static::$logLevels[$level][0];
894
+        $this->level = static::$logLevels[ $level ][ 0 ];
895 895
 
896 896
         return $this;
897 897
     }
@@ -935,25 +935,25 @@  discard block
 block discarded – undo
935 935
      * @param string|object  $message  If an object is passed it must implement __toString()
936 936
      * @param array          $context  Placeholders to be substituted in the message
937 937
      */
938
-    public function log($level, $message, array $context=[])
938
+    public function log($level, $message, array $context = [ ])
939 939
     {
940
-        $level = isset(static::$logLevels[$level]) ? $level : self::INFO;
941
-        list($logLevel, $fore, $back, $style) = static::$logLevels[$level];
940
+        $level = isset(static::$logLevels[ $level ]) ? $level : self::INFO;
941
+        list($logLevel, $fore, $back, $style) = static::$logLevels[ $level ];
942 942
         unset($style);
943
-        if ( $logLevel > $this->level )
943
+        if ($logLevel > $this->level)
944 944
         {
945
-            return ;
945
+            return;
946 946
         }
947
-        if ( is_callable($this->formatter) )
947
+        if (is_callable($this->formatter))
948 948
         {
949
-            $message = $this->formatter->__invoke(static::$logLevels[$level][4], $message, $context);
949
+            $message = $this->formatter->__invoke(static::$logLevels[ $level ][ 4 ], $message, $context);
950 950
         }
951 951
         else
952 952
         {
953 953
             $message = $this->formatMessage($level, $message, $context);
954 954
         }
955 955
         $this->lastLogEntry = $message;
956
-        $this->write($this->colourize($message, $fore, $back) . PHP_EOL);
956
+        $this->write($this->colourize($message, $fore, $back).PHP_EOL);
957 957
     }
958 958
 
959 959
     /**
@@ -963,8 +963,8 @@  discard block
 block discarded – undo
963 963
      */
964 964
     public static function style(string $style, string $message) : string
965 965
     {
966
-        $style = isset(static::$logLevels[$style]) ? $style : self::INFO;
967
-        list($logLevel, $fore, $back, $style) = static::$logLevels[$style];
966
+        $style = isset(static::$logLevels[ $style ]) ? $style : self::INFO;
967
+        list($logLevel, $fore, $back, $style) = static::$logLevels[ $style ];
968 968
         unset($logLevel, $style);
969 969
 
970 970
         return static::addColour($message, $fore, $back);
@@ -976,14 +976,14 @@  discard block
 block discarded – undo
976 976
      * @param array  $context
977 977
      * @return string
978 978
      */
979
-    protected function formatMessage(string $level, string $message, array $context=[]) : string
979
+    protected function formatMessage(string $level, string $message, array $context = [ ]) : string
980 980
     {
981 981
         # Handle objects implementing __toString
982
-        $message            = (string) $message;
983
-        $message            .= empty($context) ? '' : PHP_EOL . json_encode($context, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
984
-        $data               = $this->addDate ? ['date' => date('Y-m-d H:i:s')] : [];
985
-        $data['level']      = strtoupper(str_pad(static::$logLevels[$level][4], 5, ' ', STR_PAD_RIGHT));
986
-        $data['message']    = $message;
982
+        $message            = (string)$message;
983
+        $message .= empty($context) ? '' : PHP_EOL.json_encode($context, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
984
+        $data               = $this->addDate ? [ 'date' => date('Y-m-d H:i:s') ] : [ ];
985
+        $data[ 'level' ]      = strtoupper(str_pad(static::$logLevels[ $level ][ 4 ], 5, ' ', STR_PAD_RIGHT));
986
+        $data[ 'message' ]    = $message;
987 987
 
988 988
         return implode($this->separator, $data);
989 989
     }
@@ -996,12 +996,12 @@  discard block
 block discarded – undo
996 996
     public function write(string $content)
997 997
     {
998 998
         $resource = $this->getResource();
999
-        if ( $this->useLocking )
999
+        if ($this->useLocking)
1000 1000
         {
1001 1001
             flock($resource, LOCK_EX);
1002 1002
         }
1003 1003
         gzwrite($resource, $content);
1004
-        if ( $this->useLocking )
1004
+        if ($this->useLocking)
1005 1005
         {
1006 1006
             flock($resource, LOCK_UN);
1007 1007
         }
@@ -1013,14 +1013,14 @@  discard block
 block discarded – undo
1013 1013
      */
1014 1014
     protected function getResource()
1015 1015
     {
1016
-        if ( is_resource($this->resource) )
1016
+        if (is_resource($this->resource))
1017 1017
         {
1018 1018
             return $this->resource;
1019 1019
         }
1020 1020
         $fileName               = $this->resource;
1021 1021
         $this->closeLocally     = true;
1022 1022
         $this->resource         = $this->openResource();
1023
-        if ( ! is_resource($this->resource) )
1023
+        if ( ! is_resource($this->resource))
1024 1024
         {
1025 1025
             throw new \Exception("The resource ({$fileName}) could not be opened");
1026 1026
         }
@@ -1041,7 +1041,7 @@  discard block
 block discarded – undo
1041 1041
      */
1042 1042
     protected function openResource()
1043 1043
     {
1044
-        if ( $this->gzipFile )
1044
+        if ($this->gzipFile)
1045 1045
         {
1046 1046
             return gzopen($this->resource, 'a');
1047 1047
         }
Please login to merge, or discard this patch.
src/Validate.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -29,5 +29,5 @@  discard block
 block discarded – undo
29 29
      *
30 30
      * @var string
31 31
      */
32
-    protected $exceptionClass           = ValidationFailedException::class;
32
+    protected $exceptionClass = ValidationFailedException::class;
33 33
 }
34 34
\ No newline at end of file
Please login to merge, or discard this patch.
src/Assert.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
     /**
535 535
      * Assert that value is not equal to a provided value (using == ).
536 536
      *
537
-     * @param mixed  $value2
537
+     * @param string  $value2
538 538
      * @param string $message
539 539
      * @param string $fieldName
540 540
      * @return Assert
@@ -1408,7 +1408,7 @@  discard block
 block discarded – undo
1408 1408
     /**
1409 1409
      * Alias of {@see choice()}
1410 1410
      *
1411
-     * @param array  $choices
1411
+     * @param integer[]  $choices
1412 1412
      * @param string $message
1413 1413
      * @param string $fieldName
1414 1414
      * @return Assert
@@ -1585,7 +1585,7 @@  discard block
 block discarded – undo
1585 1585
     /**
1586 1586
      * Assert that key exists in the values array.
1587 1587
      *
1588
-     * @param string|integer $key
1588
+     * @param string $key
1589 1589
      * @param string         $message
1590 1590
      * @param string         $fieldName
1591 1591
      * @return Assert
@@ -2728,7 +2728,7 @@  discard block
 block discarded – undo
2728 2728
     }
2729 2729
 
2730 2730
     /**
2731
-     * @param $func
2731
+     * @param string $func
2732 2732
      * @param $args
2733 2733
      * @return bool
2734 2734
      * @throws AssertionFailedException
Please login to merge, or discard this patch.
Spacing   +315 added lines, -315 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
      *
137 137
      * @var string
138 138
      */
139
-    protected $exceptionClass           = AssertionFailedException::class;
139
+    protected $exceptionClass = AssertionFailedException::class;
140 140
 
141 141
     /**
142 142
      * @param mixed $value
@@ -152,16 +152,16 @@  discard block
 block discarded – undo
152 152
      */
153 153
     public static function runValidators(array $validators) : array
154 154
     {
155
-        $errors = [];
156
-        foreach ( $validators as $fieldName => $validator )
155
+        $errors = [ ];
156
+        foreach ($validators as $fieldName => $validator)
157 157
         {
158 158
             try
159 159
             {
160 160
                 $validator->__invoke();
161 161
             }
162
-            catch ( AssertionFailedException $e )
162
+            catch (AssertionFailedException $e)
163 163
             {
164
-                $errors[$fieldName]     = $e->getMessage();
164
+                $errors[ $fieldName ] = $e->getMessage();
165 165
             }
166 166
         }
167 167
 
@@ -176,22 +176,22 @@  discard block
 block discarded – undo
176 176
      * @param string $level
177 177
      * @return Assert
178 178
      */
179
-    public static function that($value, string $fieldName='', int $code=0, string $error='', string $level=Assert::WARNING) : Assert
179
+    public static function that($value, string $fieldName = '', int $code = 0, string $error = '', string $level = Assert::WARNING) : Assert
180 180
     {
181 181
         $assert = new static($value);
182
-        if ( $fieldName )
182
+        if ($fieldName)
183 183
         {
184 184
             $assert->fieldName($fieldName);
185 185
         }
186
-        if ( $code )
186
+        if ($code)
187 187
         {
188 188
             $assert->code($code);
189 189
         }
190
-        if ( $error )
190
+        if ($error)
191 191
         {
192 192
             $assert->error($error);
193 193
         }
194
-        if ( $level )
194
+        if ($level)
195 195
         {
196 196
             $assert->level($level);
197 197
         }
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
      * @param string $level
271 271
      * @return AssertionFailedException
272 272
      */
273
-    protected function createException(string $message, int $code, string $fieldName, array $constraints=[], string $level='') : AssertionFailedException
273
+    protected function createException(string $message, int $code, string $fieldName, array $constraints = [ ], string $level = '') : AssertionFailedException
274 274
     {
275 275
         $exceptionClass = $this->exceptionClass;
276 276
         $fieldName      = empty($fieldName) ? $this->fieldName : $fieldName;
@@ -372,13 +372,13 @@  discard block
 block discarded – undo
372 372
      * @return Assert
373 373
      * @throws AssertionFailedException
374 374
      */
375
-    public function eq($value2, string $message='', string $fieldName='') : Assert
375
+    public function eq($value2, string $message = '', string $fieldName = '') : Assert
376 376
     {
377
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
377
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
378 378
         {
379 379
             return $this;
380 380
         }
381
-        if ( $this->value != $value2 )
381
+        if ($this->value != $value2)
382 382
         {
383 383
             $message = $message ?: $this->overrideError;
384 384
             $message = sprintf(
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
                 $this->stringify($value2)
388 388
             );
389 389
 
390
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
390
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
391 391
         }
392 392
 
393 393
         return $this;
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
      * @return Assert
403 403
      * @throws AssertionFailedException
404 404
      */
405
-    public function greaterThan($value2, string $message='', string $fieldName='') : Assert
405
+    public function greaterThan($value2, string $message = '', string $fieldName = '') : Assert
406 406
     {
407
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
407
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
408 408
         {
409 409
             return $this;
410 410
         }
411
-        if ( ! ( $this->value > $value2 ) )
411
+        if ( ! ($this->value > $value2))
412 412
         {
413 413
             $message = $message ?: $this->overrideError;
414 414
             $message = sprintf(
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
                 $this->stringify($value2)
418 418
             );
419 419
 
420
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
420
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
421 421
         }
422 422
 
423 423
         return $this;
@@ -432,13 +432,13 @@  discard block
 block discarded – undo
432 432
      * @return Assert
433 433
      * @throws AssertionFailedException
434 434
      */
435
-    public function greaterThanOrEq($value2, string $message='', string $fieldName='') : Assert
435
+    public function greaterThanOrEq($value2, string $message = '', string $fieldName = '') : Assert
436 436
     {
437
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
437
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
438 438
         {
439 439
             return $this;
440 440
         }
441
-        if ( ! ( $this->value >= $value2 ) )
441
+        if ( ! ($this->value >= $value2))
442 442
         {
443 443
             $message = $message ?: $this->overrideError;
444 444
             $message = sprintf(
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                 $this->stringify($value2)
448 448
             );
449 449
 
450
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, ['expected' => $value2]);
450
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_EQ, $fieldName, [ 'expected' => $value2 ]);
451 451
         }
452 452
 
453 453
         return $this;
@@ -462,13 +462,13 @@  discard block
 block discarded – undo
462 462
      * @return Assert
463 463
      * @throws AssertionFailedException
464 464
      */
465
-    public function lessThan($value2, string $message='', string $fieldName='') : Assert
465
+    public function lessThan($value2, string $message = '', string $fieldName = '') : Assert
466 466
     {
467
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
467
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
468 468
         {
469 469
             return $this;
470 470
         }
471
-        if ( ! ( $this->value < $value2 ) )
471
+        if ( ! ($this->value < $value2))
472 472
         {
473 473
             $message = $message ?: $this->overrideError;
474 474
             $message = sprintf(
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
                 $this->stringify($value2)
478 478
             );
479 479
 
480
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, ['expected' => $value2]);
480
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN, $fieldName, [ 'expected' => $value2 ]);
481 481
         }
482 482
 
483 483
         return $this;
@@ -492,13 +492,13 @@  discard block
 block discarded – undo
492 492
      * @return Assert
493 493
      * @throws AssertionFailedException
494 494
      */
495
-    public function lessThanOrEq($value2, string $message='', string $fieldName='') : Assert
495
+    public function lessThanOrEq($value2, string $message = '', string $fieldName = '') : Assert
496 496
     {
497
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
497
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
498 498
         {
499 499
             return $this;
500 500
         }
501
-        if ( ! ( $this->value <= $value2 ) )
501
+        if ( ! ($this->value <= $value2))
502 502
         {
503 503
             $message = $message ?: $this->overrideError;
504 504
             $message = sprintf(
@@ -507,7 +507,7 @@  discard block
 block discarded – undo
507 507
                 $this->stringify($value2)
508 508
             );
509 509
 
510
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, ['expected' => $value2]);
510
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_LESS_THAN_OR_EQ, $fieldName, [ 'expected' => $value2 ]);
511 511
         }
512 512
 
513 513
         return $this;
@@ -522,13 +522,13 @@  discard block
 block discarded – undo
522 522
      * @return Assert
523 523
      * @throws AssertionFailedException
524 524
      */
525
-    public function same($value2, string $message='', string $fieldName='') : Assert
525
+    public function same($value2, string $message = '', string $fieldName = '') : Assert
526 526
     {
527
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
527
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
528 528
         {
529 529
             return $this;
530 530
         }
531
-        if ( $this->value !== $value2 )
531
+        if ($this->value !== $value2)
532 532
         {
533 533
             $message = $message ?: $this->overrideError;
534 534
             $message = sprintf(
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
                 $this->stringify($value2)
538 538
             );
539 539
 
540
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $fieldName, ['expected' => $value2]);
540
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SAME, $fieldName, [ 'expected' => $value2 ]);
541 541
         }
542 542
 
543 543
         return $this;
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
      * @return Assert
553 553
      * @throws AssertionFailedException
554 554
      */
555
-    public function notEq($value2, string $message='', string $fieldName='') : Assert
555
+    public function notEq($value2, string $message = '', string $fieldName = '') : Assert
556 556
     {
557
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
557
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
558 558
         {
559 559
             return $this;
560 560
         }
561
-        if ( $this->value == $value2 )
561
+        if ($this->value == $value2)
562 562
         {
563 563
             $message = $message ?: $this->overrideError;
564 564
             $message = sprintf(
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
                 $this->stringify($value2)
568 568
             );
569 569
 
570
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, ['expected' => $value2]);
570
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_EQ, $fieldName, [ 'expected' => $value2 ]);
571 571
         }
572 572
 
573 573
         return $this;
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
      * @return Assert
582 582
      * @throws AssertionFailedException
583 583
      */
584
-    public function isCallable(string $message='', string $fieldName='') : Assert
584
+    public function isCallable(string $message = '', string $fieldName = '') : Assert
585 585
     {
586
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
586
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
587 587
         {
588 588
             return $this;
589 589
         }
590
-        if ( !is_callable($this->value) )
590
+        if ( ! is_callable($this->value))
591 591
         {
592 592
             $message = $message ?: $this->overrideError;
593 593
             $message = sprintf(
@@ -610,13 +610,13 @@  discard block
 block discarded – undo
610 610
      * @return Assert
611 611
      * @throws AssertionFailedException
612 612
      */
613
-    public function notSame($value2, string $message='', string $fieldName='') : Assert
613
+    public function notSame($value2, string $message = '', string $fieldName = '') : Assert
614 614
     {
615
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
615
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
616 616
         {
617 617
             return $this;
618 618
         }
619
-        if ( $this->value === $value2 )
619
+        if ($this->value === $value2)
620 620
         {
621 621
             $message = $message ?: $this->overrideError;
622 622
             $message = sprintf(
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
                 $this->stringify($value2)
626 626
             );
627 627
 
628
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, ['expected' => $value2]);
628
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_SAME, $fieldName, [ 'expected' => $value2 ]);
629 629
         }
630 630
 
631 631
         return $this;
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
      * @return Assert
640 640
      * @throws AssertionFailedException
641 641
      */
642
-    public function id(string $message='', string $fieldName='') : Assert
642
+    public function id(string $message = '', string $fieldName = '') : Assert
643 643
     {
644 644
         $message = $message ?: $this->overrideError;
645 645
         $message = $message ?: 'Value "%s" is not an integer id.';
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      * @return Assert
655 655
      * @throws AssertionFailedException
656 656
      */
657
-    public function unsignedInt(string $message='', string $fieldName='') : Assert
657
+    public function unsignedInt(string $message = '', string $fieldName = '') : Assert
658 658
     {
659 659
         $message = $message ?: $this->overrideError;
660 660
         $message = $message ?: 'Value "%s" is not an integer id.';
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
      * @return Assert
671 671
      * @throws AssertionFailedException
672 672
      */
673
-    public function flag(string $message='', string $fieldName='') : Assert
673
+    public function flag(string $message = '', string $fieldName = '') : Assert
674 674
     {
675 675
         $message = $message ?: $this->overrideError;
676 676
         $message = $message ?: 'Value "%s" is not a 0 or 1.';
@@ -686,12 +686,12 @@  discard block
 block discarded – undo
686 686
      * @return Assert
687 687
      * @throws AssertionFailedException
688 688
      */
689
-    public function status(string $message='', string $fieldName='') : Assert
689
+    public function status(string $message = '', string $fieldName = '') : Assert
690 690
     {
691 691
         $message = $message ?: $this->overrideError;
692 692
         $message = $message ?: 'Value "%s" is not a valid status.';
693 693
 
694
-        return $this->integer($message, $fieldName)->inArray([-1, 0, 1]);
694
+        return $this->integer($message, $fieldName)->inArray([-1, 0, 1 ]);
695 695
     }
696 696
 
697 697
     /**
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
      * @return Assert
703 703
      * @throws AssertionFailedException
704 704
      */
705
-    public function nullOrId(string $message='', string $fieldName='') : Assert
705
+    public function nullOrId(string $message = '', string $fieldName = '') : Assert
706 706
     {
707 707
         return $this->nullOr()->id($message, $fieldName);
708 708
     }
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
      * @return Assert
716 716
      * @throws AssertionFailedException
717 717
      */
718
-    public function allIds(string $message='', string $fieldName='') : Assert
718
+    public function allIds(string $message = '', string $fieldName = '') : Assert
719 719
     {
720 720
         return $this->all()->id($message, $fieldName);
721 721
     }
@@ -728,7 +728,7 @@  discard block
 block discarded – undo
728 728
      * @return Assert
729 729
      * @throws AssertionFailedException
730 730
      */
731
-    public function int(string $message='', string $fieldName='') : Assert
731
+    public function int(string $message = '', string $fieldName = '') : Assert
732 732
     {
733 733
         return $this->integer($message, $fieldName);
734 734
     }
@@ -741,13 +741,13 @@  discard block
 block discarded – undo
741 741
      * @return Assert
742 742
      * @throws AssertionFailedException
743 743
      */
744
-    public function integer(string $message='', string $fieldName='') : Assert
744
+    public function integer(string $message = '', string $fieldName = '') : Assert
745 745
     {
746
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
746
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
747 747
         {
748 748
             return $this;
749 749
         }
750
-        if ( !is_int($this->value) )
750
+        if ( ! is_int($this->value))
751 751
         {
752 752
             $message = $message ?: $this->overrideError;
753 753
             $message = sprintf(
@@ -769,13 +769,13 @@  discard block
 block discarded – undo
769 769
      * @return Assert
770 770
      * @throws AssertionFailedException
771 771
      */
772
-    public function float(string $message='', string $fieldName='') : Assert
772
+    public function float(string $message = '', string $fieldName = '') : Assert
773 773
     {
774
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
774
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
775 775
         {
776 776
             return $this;
777 777
         }
778
-        if ( ! is_float($this->value) )
778
+        if ( ! is_float($this->value))
779 779
         {
780 780
             $message = $message ?: $this->overrideError;
781 781
             $message = sprintf(
@@ -797,13 +797,13 @@  discard block
 block discarded – undo
797 797
      * @return Assert
798 798
      * @throws AssertionFailedException
799 799
      */
800
-    public function digit(string $message='', string $fieldName='') : Assert
800
+    public function digit(string $message = '', string $fieldName = '') : Assert
801 801
     {
802
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
802
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
803 803
         {
804 804
             return $this;
805 805
         }
806
-        if ( ! ctype_digit((string)$this->value) )
806
+        if ( ! ctype_digit((string)$this->value))
807 807
         {
808 808
             $message = $message ?: $this->overrideError;
809 809
             $message = sprintf(
@@ -825,14 +825,14 @@  discard block
 block discarded – undo
825 825
      * @return Assert
826 826
      * @throws AssertionFailedException
827 827
      */
828
-    public function date(string $message='', string $fieldName='') : Assert
828
+    public function date(string $message = '', string $fieldName = '') : Assert
829 829
     {
830
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
830
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
831 831
         {
832 832
             return $this;
833 833
         }
834 834
         $this->notEmpty($message, $fieldName);
835
-        if ( strtotime($this->value) === false )
835
+        if (strtotime($this->value) === false)
836 836
         {
837 837
             $message = $message ?: $this->overrideError;
838 838
             $message = sprintf(
@@ -853,14 +853,14 @@  discard block
 block discarded – undo
853 853
      * @return $this
854 854
      * @throws AssertionFailedException
855 855
      */
856
-    public function after($afterDate, string $message='', string $fieldName='')
856
+    public function after($afterDate, string $message = '', string $fieldName = '')
857 857
     {
858
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
858
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
859 859
         {
860 860
             return $this;
861 861
         }
862 862
         $this->notEmpty($message, $fieldName);
863
-        if ( strtotime($this->value) === false && strtotime($afterDate) === false && strtotime($this->value) < strtotime($afterDate) )
863
+        if (strtotime($this->value) === false && strtotime($afterDate) === false && strtotime($this->value) < strtotime($afterDate))
864 864
         {
865 865
             $message = $message ?: $this->overrideError;
866 866
             $message = sprintf(
@@ -882,13 +882,13 @@  discard block
 block discarded – undo
882 882
      * @return Assert
883 883
      * @throws AssertionFailedException
884 884
      */
885
-    public function integerish(string $message='', string $fieldName='') : Assert
885
+    public function integerish(string $message = '', string $fieldName = '') : Assert
886 886
     {
887
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
887
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
888 888
         {
889 889
             return $this;
890 890
         }
891
-        if ( is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value) )
891
+        if (is_object($this->value) || strval(intval($this->value)) != $this->value || is_bool($this->value) || is_null($this->value))
892 892
         {
893 893
             $message = $message ?: $this->overrideError;
894 894
             $message = sprintf(
@@ -910,13 +910,13 @@  discard block
 block discarded – undo
910 910
      * @return Assert
911 911
      * @throws AssertionFailedException
912 912
      */
913
-    public function boolean(string $message='', string $fieldName='') : Assert
913
+    public function boolean(string $message = '', string $fieldName = '') : Assert
914 914
     {
915
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
915
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
916 916
         {
917 917
             return $this;
918 918
         }
919
-        if ( ! is_bool($this->value) )
919
+        if ( ! is_bool($this->value))
920 920
         {
921 921
             $message = $message ?: $this->overrideError;
922 922
             $message = sprintf(
@@ -938,13 +938,13 @@  discard block
 block discarded – undo
938 938
      * @return Assert
939 939
      * @throws AssertionFailedException
940 940
      */
941
-    public function scalar(string $message='', string $fieldName='') : Assert
941
+    public function scalar(string $message = '', string $fieldName = '') : Assert
942 942
     {
943
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
943
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
944 944
         {
945 945
             return $this;
946 946
         }
947
-        if ( ! is_scalar($this->value) )
947
+        if ( ! is_scalar($this->value))
948 948
         {
949 949
             $message = $message ?: $this->overrideError;
950 950
             $message = sprintf(
@@ -966,13 +966,13 @@  discard block
 block discarded – undo
966 966
      * @return Assert
967 967
      * @throws AssertionFailedException
968 968
      */
969
-    public function notEmpty(string $message='', string $fieldName='') : Assert
969
+    public function notEmpty(string $message = '', string $fieldName = '') : Assert
970 970
     {
971
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
971
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
972 972
         {
973 973
             return $this;
974 974
         }
975
-        if ( ( is_object($this->value) && empty((array)$this->value) ) || empty($this->value) )
975
+        if ((is_object($this->value) && empty((array)$this->value)) || empty($this->value))
976 976
         {
977 977
             $message = $message ?: $this->overrideError;
978 978
             $message = sprintf(
@@ -994,13 +994,13 @@  discard block
 block discarded – undo
994 994
      * @return Assert
995 995
      * @throws AssertionFailedException
996 996
      */
997
-    public function noContent(string $message='', string $fieldName='') : Assert
997
+    public function noContent(string $message = '', string $fieldName = '') : Assert
998 998
     {
999
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
999
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1000 1000
         {
1001 1001
             return $this;
1002 1002
         }
1003
-        if ( !empty( $this->value ) )
1003
+        if ( ! empty($this->value))
1004 1004
         {
1005 1005
             $message = $message ?: $this->overrideError;
1006 1006
             $message = sprintf(
@@ -1022,13 +1022,13 @@  discard block
 block discarded – undo
1022 1022
      * @return Assert
1023 1023
      * @throws AssertionFailedException
1024 1024
      */
1025
-    public function notNull(string $message='', string $fieldName='') : Assert
1025
+    public function notNull(string $message = '', string $fieldName = '') : Assert
1026 1026
     {
1027
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1027
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1028 1028
         {
1029 1029
             return $this;
1030 1030
         }
1031
-        if ( $this->value === null )
1031
+        if ($this->value === null)
1032 1032
         {
1033 1033
             $message = $message ?: $this->overrideError;
1034 1034
             $message = sprintf(
@@ -1050,13 +1050,13 @@  discard block
 block discarded – undo
1050 1050
      * @return Assert
1051 1051
      * @throws AssertionFailedException
1052 1052
      */
1053
-    public function string(string $message='', string $fieldName='') : Assert
1053
+    public function string(string $message = '', string $fieldName = '') : Assert
1054 1054
     {
1055
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1055
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1056 1056
         {
1057 1057
             return $this;
1058 1058
         }
1059
-        if ( !is_string($this->value) )
1059
+        if ( ! is_string($this->value))
1060 1060
         {
1061 1061
             $message = $message ?: $this->overrideError;
1062 1062
             $message = sprintf(
@@ -1080,14 +1080,14 @@  discard block
 block discarded – undo
1080 1080
      * @return Assert
1081 1081
      * @throws AssertionFailedException
1082 1082
      */
1083
-    public function regex(string $pattern, string $message='', string $fieldName='') : Assert
1083
+    public function regex(string $pattern, string $message = '', string $fieldName = '') : Assert
1084 1084
     {
1085
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1085
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1086 1086
         {
1087 1087
             return $this;
1088 1088
         }
1089 1089
         $this->string($message, $fieldName);
1090
-        if ( ! preg_match($pattern, $this->value) )
1090
+        if ( ! preg_match($pattern, $this->value))
1091 1091
         {
1092 1092
             $message = $message ?: $this->overrideError;
1093 1093
             $message = sprintf(
@@ -1095,7 +1095,7 @@  discard block
 block discarded – undo
1095 1095
                 $this->stringify($this->value)
1096 1096
             );
1097 1097
 
1098
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1098
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1099 1099
         }
1100 1100
 
1101 1101
         return $this;
@@ -1109,15 +1109,15 @@  discard block
 block discarded – undo
1109 1109
      * @return Assert
1110 1110
      * @throws AssertionFailedException
1111 1111
      */
1112
-    public function ipAddress(string $message='', string $fieldName='') : Assert
1112
+    public function ipAddress(string $message = '', string $fieldName = '') : Assert
1113 1113
     {
1114
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1114
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1115 1115
         {
1116 1116
             return $this;
1117 1117
         }
1118 1118
         $this->string($message, $fieldName);
1119
-        $pattern   = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
1120
-        if ( ! preg_match($pattern, $this->value) )
1119
+        $pattern = '/^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/';
1120
+        if ( ! preg_match($pattern, $this->value))
1121 1121
         {
1122 1122
             $message = $message ?: $this->overrideError;
1123 1123
             $message = sprintf(
@@ -1140,14 +1140,14 @@  discard block
 block discarded – undo
1140 1140
      * @return Assert
1141 1141
      * @throws AssertionFailedException
1142 1142
      */
1143
-    public function notRegex(string $pattern, string $message='', string $fieldName='') : Assert
1143
+    public function notRegex(string $pattern, string $message = '', string $fieldName = '') : Assert
1144 1144
     {
1145
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1145
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1146 1146
         {
1147 1147
             return $this;
1148 1148
         }
1149 1149
         $this->string($message, $fieldName);
1150
-        if ( preg_match($pattern, $this->value) )
1150
+        if (preg_match($pattern, $this->value))
1151 1151
         {
1152 1152
             $message = $message ?: $this->overrideError;
1153 1153
             $message = sprintf(
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
                 $this->stringify($this->value)
1156 1156
             );
1157 1157
 
1158
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, ['pattern' => $pattern]);
1158
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_REGEX, $fieldName, [ 'pattern' => $pattern ]);
1159 1159
         }
1160 1160
 
1161 1161
         return $this;
@@ -1171,14 +1171,14 @@  discard block
 block discarded – undo
1171 1171
      * @return Assert
1172 1172
      * @throws AssertionFailedException
1173 1173
      */
1174
-    public function length(int $length, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1174
+    public function length(int $length, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1175 1175
     {
1176
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1176
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1177 1177
         {
1178 1178
             return $this;
1179 1179
         }
1180 1180
         $this->string($message, $fieldName);
1181
-        if ( mb_strlen($this->value, $encoding) !== $length )
1181
+        if (mb_strlen($this->value, $encoding) !== $length)
1182 1182
         {
1183 1183
             $message    = $message ?: $this->overrideError;
1184 1184
             $message    = sprintf(
@@ -1187,7 +1187,7 @@  discard block
 block discarded – undo
1187 1187
                 $length,
1188 1188
                 mb_strlen($this->value, $encoding)
1189 1189
             );
1190
-            $constraints = ['length' => $length, 'encoding' => $encoding];
1190
+            $constraints = [ 'length' => $length, 'encoding' => $encoding ];
1191 1191
 
1192 1192
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_LENGTH, $fieldName, $constraints);
1193 1193
         }
@@ -1206,24 +1206,24 @@  discard block
 block discarded – undo
1206 1206
      * @return Assert
1207 1207
      * @throws AssertionFailedException
1208 1208
      */
1209
-    public function minLength(int $minLength, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1209
+    public function minLength(int $minLength, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1210 1210
     {
1211
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1211
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1212 1212
         {
1213 1213
             return $this;
1214 1214
         }
1215 1215
         $this->string($message, $fieldName);
1216
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1216
+        if (mb_strlen($this->value, $encoding) < $minLength)
1217 1217
         {
1218 1218
             $message = $message ?: $this->overrideError;
1219
-            $message     = sprintf(
1219
+            $message = sprintf(
1220 1220
                 $message
1221 1221
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1222 1222
                 $this->stringify($this->value),
1223 1223
                 $minLength,
1224 1224
                 mb_strlen($this->value, $encoding)
1225 1225
             );
1226
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1226
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1227 1227
 
1228 1228
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1229 1229
         }
@@ -1242,23 +1242,23 @@  discard block
 block discarded – undo
1242 1242
      * @return Assert
1243 1243
      * @throws AssertionFailedException
1244 1244
      */
1245
-    public function maxLength(int $maxLength, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1245
+    public function maxLength(int $maxLength, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1246 1246
     {
1247
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1247
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1248 1248
         {
1249 1249
             return $this;
1250 1250
         }
1251 1251
         $this->string($message, $fieldName);
1252
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1252
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1253 1253
         {
1254 1254
             $message = $message ?: $this->overrideError;
1255
-            $message     = sprintf(
1255
+            $message = sprintf(
1256 1256
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1257 1257
                 $this->stringify($this->value),
1258 1258
                 $maxLength,
1259 1259
                 mb_strlen($this->value, $encoding)
1260 1260
             );
1261
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1261
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1262 1262
 
1263 1263
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1264 1264
         }
@@ -1277,37 +1277,37 @@  discard block
 block discarded – undo
1277 1277
      * @return Assert
1278 1278
      * @throws AssertionFailedException
1279 1279
      */
1280
-    public function betweenLength(int $minLength, int $maxLength, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1280
+    public function betweenLength(int $minLength, int $maxLength, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1281 1281
     {
1282
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1282
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1283 1283
         {
1284 1284
             return $this;
1285 1285
         }
1286 1286
         $this->string($message, $fieldName);
1287
-        if ( mb_strlen($this->value, $encoding) < $minLength )
1287
+        if (mb_strlen($this->value, $encoding) < $minLength)
1288 1288
         {
1289 1289
             $message = $message ?: $this->overrideError;
1290
-            $message     = sprintf(
1290
+            $message = sprintf(
1291 1291
                 $message
1292 1292
                     ?: 'Value "%s" is too short, it should have more than %d characters, but only has %d characters.',
1293 1293
                 $this->stringify($this->value),
1294 1294
                 $minLength,
1295 1295
                 mb_strlen($this->value, $encoding)
1296 1296
             );
1297
-            $constraints = ['min_length' => $minLength, 'encoding' => $encoding];
1297
+            $constraints = [ 'min_length' => $minLength, 'encoding' => $encoding ];
1298 1298
 
1299 1299
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN_LENGTH, $fieldName, $constraints);
1300 1300
         }
1301
-        if ( mb_strlen($this->value, $encoding) > $maxLength )
1301
+        if (mb_strlen($this->value, $encoding) > $maxLength)
1302 1302
         {
1303 1303
             $message = $message ?: $this->overrideError;
1304
-            $message     = sprintf(
1304
+            $message = sprintf(
1305 1305
                 $message ?: 'Value "%s" is too long, it should have no more than %d characters, but has %d characters.',
1306 1306
                 $this->stringify($this->value),
1307 1307
                 $maxLength,
1308 1308
                 mb_strlen($this->value, $encoding)
1309 1309
             );
1310
-            $constraints = ['max_length' => $maxLength, 'encoding' => $encoding];
1310
+            $constraints = [ 'max_length' => $maxLength, 'encoding' => $encoding ];
1311 1311
 
1312 1312
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX_LENGTH, $fieldName, $constraints);
1313 1313
         }
@@ -1325,22 +1325,22 @@  discard block
 block discarded – undo
1325 1325
      * @return Assert
1326 1326
      * @throws AssertionFailedException
1327 1327
      */
1328
-    public function startsWith(string $needle, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1328
+    public function startsWith(string $needle, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1329 1329
     {
1330
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1330
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1331 1331
         {
1332 1332
             return $this;
1333 1333
         }
1334 1334
         $this->string($message, $fieldName);
1335
-        if ( mb_strpos($this->value, $needle, 0, $encoding) !== 0 )
1335
+        if (mb_strpos($this->value, $needle, 0, $encoding) !== 0)
1336 1336
         {
1337 1337
             $message = $message ?: $this->overrideError;
1338
-            $message     = sprintf(
1338
+            $message = sprintf(
1339 1339
                 $message ?: 'Value "%s" does not start with "%s".',
1340 1340
                 $this->stringify($this->value),
1341 1341
                 $this->stringify($needle)
1342 1342
             );
1343
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1343
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1344 1344
 
1345 1345
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_START, $fieldName, $constraints);
1346 1346
         }
@@ -1358,23 +1358,23 @@  discard block
 block discarded – undo
1358 1358
      * @return Assert
1359 1359
      * @throws AssertionFailedException
1360 1360
      */
1361
-    public function endsWith(string $needle, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1361
+    public function endsWith(string $needle, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1362 1362
     {
1363
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1363
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1364 1364
         {
1365 1365
             return $this;
1366 1366
         }
1367 1367
         $this->string($message, $fieldName);
1368 1368
         $stringPosition = mb_strlen($this->value, $encoding) - mb_strlen($needle, $encoding);
1369
-        if ( mb_strripos($this->value, $needle, 0 , $encoding) !== $stringPosition )
1369
+        if (mb_strripos($this->value, $needle, 0, $encoding) !== $stringPosition)
1370 1370
         {
1371 1371
             $message = $message ?: $this->overrideError;
1372
-            $message     = sprintf(
1372
+            $message = sprintf(
1373 1373
                 $message ?: 'Value "%s" does not end with "%s".',
1374 1374
                 $this->stringify($this->value),
1375 1375
                 $this->stringify($needle)
1376 1376
             );
1377
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1377
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1378 1378
 
1379 1379
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_END, $fieldName, $constraints);
1380 1380
         }
@@ -1392,22 +1392,22 @@  discard block
 block discarded – undo
1392 1392
      * @return Assert
1393 1393
      * @throws AssertionFailedException
1394 1394
      */
1395
-    public function contains(string $needle, string $message='', string $fieldName='', string $encoding='utf8') : Assert
1395
+    public function contains(string $needle, string $message = '', string $fieldName = '', string $encoding = 'utf8') : Assert
1396 1396
     {
1397
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1397
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1398 1398
         {
1399 1399
             return $this;
1400 1400
         }
1401 1401
         $this->string($message, $fieldName);
1402
-        if ( mb_strpos($this->value, $needle, 0, $encoding) === false )
1402
+        if (mb_strpos($this->value, $needle, 0, $encoding) === false)
1403 1403
         {
1404 1404
             $message = $message ?: $this->overrideError;
1405
-            $message     = sprintf(
1405
+            $message = sprintf(
1406 1406
                 $message ?: 'Value "%s" does not contain "%s".',
1407 1407
                 $this->stringify($this->value),
1408 1408
                 $this->stringify($needle)
1409 1409
             );
1410
-            $constraints = ['needle' => $needle, 'encoding' => $encoding];
1410
+            $constraints = [ 'needle' => $needle, 'encoding' => $encoding ];
1411 1411
 
1412 1412
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_STRING_CONTAINS, $fieldName, $constraints);
1413 1413
         }
@@ -1424,13 +1424,13 @@  discard block
 block discarded – undo
1424 1424
      * @return Assert
1425 1425
      * @throws AssertionFailedException
1426 1426
      */
1427
-    public function choice(array $choices, string $message='', string $fieldName='') : Assert
1427
+    public function choice(array $choices, string $message = '', string $fieldName = '') : Assert
1428 1428
     {
1429
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1429
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1430 1430
         {
1431 1431
             return $this;
1432 1432
         }
1433
-        if ( !in_array($this->value, $choices, true) )
1433
+        if ( ! in_array($this->value, $choices, true))
1434 1434
         {
1435 1435
             $message = $message ?: $this->overrideError;
1436 1436
             $message = sprintf(
@@ -1439,7 +1439,7 @@  discard block
 block discarded – undo
1439 1439
                 implode(", ", array_map('Terah\Assert\Assert::stringify', $choices))
1440 1440
             );
1441 1441
 
1442
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, ['choices' => $choices]);
1442
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_CHOICE, $fieldName, [ 'choices' => $choices ]);
1443 1443
         }
1444 1444
 
1445 1445
         return $this;
@@ -1454,9 +1454,9 @@  discard block
 block discarded – undo
1454 1454
      * @return Assert
1455 1455
      * @throws AssertionFailedException
1456 1456
      */
1457
-    public function inArray(array $choices, string $message='', string $fieldName='') : Assert
1457
+    public function inArray(array $choices, string $message = '', string $fieldName = '') : Assert
1458 1458
     {
1459
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1459
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1460 1460
         {
1461 1461
             return $this;
1462 1462
         }
@@ -1473,13 +1473,13 @@  discard block
 block discarded – undo
1473 1473
      * @return Assert
1474 1474
      * @throws AssertionFailedException
1475 1475
      */
1476
-    public function numeric(string $message='', string $fieldName='') : Assert
1476
+    public function numeric(string $message = '', string $fieldName = '') : Assert
1477 1477
     {
1478
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1478
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1479 1479
         {
1480 1480
             return $this;
1481 1481
         }
1482
-        if ( ! is_numeric($this->value) )
1482
+        if ( ! is_numeric($this->value))
1483 1483
         {
1484 1484
             $message = $message ?: $this->overrideError;
1485 1485
             $message = sprintf(
@@ -1501,7 +1501,7 @@  discard block
 block discarded – undo
1501 1501
      * @return Assert
1502 1502
      * @throws AssertionFailedException
1503 1503
      */
1504
-    public function nonEmptyArray(string $message='', string $fieldName='') : Assert
1504
+    public function nonEmptyArray(string $message = '', string $fieldName = '') : Assert
1505 1505
     {
1506 1506
         $message = $message ?: 'Value "%s" is not a non-empty array.';
1507 1507
 
@@ -1516,7 +1516,7 @@  discard block
 block discarded – undo
1516 1516
      * @return Assert
1517 1517
      * @throws AssertionFailedException
1518 1518
      */
1519
-    public function nonEmptyInt(string $message='', string $fieldName='') : Assert
1519
+    public function nonEmptyInt(string $message = '', string $fieldName = '') : Assert
1520 1520
     {
1521 1521
         $message = $message ?: 'Value "%s" is not a non-empty integer.';
1522 1522
 
@@ -1531,7 +1531,7 @@  discard block
 block discarded – undo
1531 1531
      * @return Assert
1532 1532
      * @throws AssertionFailedException
1533 1533
      */
1534
-    public function nonEmptyString(string $message='', string $fieldName='') : Assert
1534
+    public function nonEmptyString(string $message = '', string $fieldName = '') : Assert
1535 1535
     {
1536 1536
         $message = $message ?: 'Value "%s" is not a non-empty string.';
1537 1537
 
@@ -1546,13 +1546,13 @@  discard block
 block discarded – undo
1546 1546
      * @return Assert
1547 1547
      * @throws AssertionFailedException
1548 1548
      */
1549
-    public function isArray(string $message='', string $fieldName='') : Assert
1549
+    public function isArray(string $message = '', string $fieldName = '') : Assert
1550 1550
     {
1551
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1551
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1552 1552
         {
1553 1553
             return $this;
1554 1554
         }
1555
-        if ( !is_array($this->value) )
1555
+        if ( ! is_array($this->value))
1556 1556
         {
1557 1557
             $message = $message ?: $this->overrideError;
1558 1558
             $message = sprintf(
@@ -1574,13 +1574,13 @@  discard block
 block discarded – undo
1574 1574
      * @return Assert
1575 1575
      * @throws AssertionFailedException
1576 1576
      */
1577
-    public function isTraversable(string $message='', string $fieldName='') : Assert
1577
+    public function isTraversable(string $message = '', string $fieldName = '') : Assert
1578 1578
     {
1579
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1579
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1580 1580
         {
1581 1581
             return $this;
1582 1582
         }
1583
-        if ( !is_array($this->value) && !$this->value instanceof \Traversable )
1583
+        if ( ! is_array($this->value) && ! $this->value instanceof \Traversable)
1584 1584
         {
1585 1585
             $message = $message ?: $this->overrideError;
1586 1586
             $message = sprintf(
@@ -1602,13 +1602,13 @@  discard block
 block discarded – undo
1602 1602
      * @return Assert
1603 1603
      * @throws AssertionFailedException
1604 1604
      */
1605
-    public function isArrayAccessible(string $message='', string $fieldName='') : Assert
1605
+    public function isArrayAccessible(string $message = '', string $fieldName = '') : Assert
1606 1606
     {
1607
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1607
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1608 1608
         {
1609 1609
             return $this;
1610 1610
         }
1611
-        if ( !is_array($this->value) && !$this->value instanceof \ArrayAccess )
1611
+        if ( ! is_array($this->value) && ! $this->value instanceof \ArrayAccess)
1612 1612
         {
1613 1613
             $message = $message ?: $this->overrideError;
1614 1614
             $message = sprintf(
@@ -1631,14 +1631,14 @@  discard block
 block discarded – undo
1631 1631
      * @return Assert
1632 1632
      * @throws AssertionFailedException
1633 1633
      */
1634
-    public function keyExists($key, string $message='', string $fieldName='') : Assert
1634
+    public function keyExists($key, string $message = '', string $fieldName = '') : Assert
1635 1635
     {
1636
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1636
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1637 1637
         {
1638 1638
             return $this;
1639 1639
         }
1640 1640
         $this->isArray($message, $fieldName);
1641
-        if ( !array_key_exists($key, $this->value) )
1641
+        if ( ! array_key_exists($key, $this->value))
1642 1642
         {
1643 1643
             $message = $message ?: $this->overrideError;
1644 1644
             $message = sprintf(
@@ -1646,7 +1646,7 @@  discard block
 block discarded – undo
1646 1646
                 $this->stringify($key)
1647 1647
             );
1648 1648
 
1649
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, ['key' => $key]);
1649
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_EXISTS, $fieldName, [ 'key' => $key ]);
1650 1650
         }
1651 1651
 
1652 1652
         return $this;
@@ -1661,23 +1661,23 @@  discard block
 block discarded – undo
1661 1661
      * @return Assert
1662 1662
      * @throws AssertionFailedException
1663 1663
      */
1664
-    public function keysExist(array $keys, string $message='', string $fieldName='') : Assert
1664
+    public function keysExist(array $keys, string $message = '', string $fieldName = '') : Assert
1665 1665
     {
1666
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1666
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1667 1667
         {
1668 1668
             return $this;
1669 1669
         }
1670 1670
         $this->isArray($message, $fieldName);
1671
-        foreach ( $keys as $key )
1671
+        foreach ($keys as $key)
1672 1672
         {
1673
-            if ( !array_key_exists($key, $this->value) )
1673
+            if ( ! array_key_exists($key, $this->value))
1674 1674
             {
1675 1675
                 $message = $message
1676 1676
                     ?: sprintf(
1677 1677
                         'Array does not contain an element with key "%s"',
1678 1678
                         $this->stringify($key)
1679 1679
                     );
1680
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, ['key' => $key]);
1680
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEYS_EXIST, $fieldName, [ 'key' => $key ]);
1681 1681
             }
1682 1682
         }
1683 1683
 
@@ -1693,14 +1693,14 @@  discard block
 block discarded – undo
1693 1693
      * @return Assert
1694 1694
      * @throws AssertionFailedException
1695 1695
      */
1696
-    public function propertyExists($key, string $message='', string $fieldName='') : Assert
1696
+    public function propertyExists($key, string $message = '', string $fieldName = '') : Assert
1697 1697
     {
1698
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1698
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1699 1699
         {
1700 1700
             return $this;
1701 1701
         }
1702 1702
         $this->isObject($message, $fieldName);
1703
-        if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1703
+        if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1704 1704
         {
1705 1705
             $message = $message
1706 1706
                 ?: sprintf(
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
                     $this->stringify($key)
1709 1709
                 );
1710 1710
 
1711
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, ['key' => $key]);
1711
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTY_EXISTS, $fieldName, [ 'key' => $key ]);
1712 1712
         }
1713 1713
 
1714 1714
         return $this;
@@ -1723,24 +1723,24 @@  discard block
 block discarded – undo
1723 1723
      * @return Assert
1724 1724
      * @throws AssertionFailedException
1725 1725
      */
1726
-    public function propertiesExist(array $keys, string $message='', string $fieldName='') : Assert
1726
+    public function propertiesExist(array $keys, string $message = '', string $fieldName = '') : Assert
1727 1727
     {
1728
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1728
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1729 1729
         {
1730 1730
             return $this;
1731 1731
         }
1732 1732
         $this->isObject($message, $fieldName);
1733
-        foreach ( $keys as $key )
1733
+        foreach ($keys as $key)
1734 1734
         {
1735 1735
             // Using isset to allow resolution of magically defined properties
1736
-            if ( !property_exists($this->value, $key) && !isset( $this->value->{$key} ) )
1736
+            if ( ! property_exists($this->value, $key) && ! isset($this->value->{$key} ))
1737 1737
             {
1738 1738
                 $message = $message
1739 1739
                     ?: sprintf(
1740 1740
                         'Object does not contain a property with key "%s"',
1741 1741
                         $this->stringify($key)
1742 1742
                     );
1743
-                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, ['key' => $key]);
1743
+                throw $this->createException($message, $this->overrideCode ?: self::INVALID_PROPERTIES_EXIST, $fieldName, [ 'key' => $key ]);
1744 1744
             }
1745 1745
         }
1746 1746
 
@@ -1755,14 +1755,14 @@  discard block
 block discarded – undo
1755 1755
      * @return Assert
1756 1756
      * @throws AssertionFailedException
1757 1757
      */
1758
-    public function utf8(string $message='', string $fieldName='') : Assert
1758
+    public function utf8(string $message = '', string $fieldName = '') : Assert
1759 1759
     {
1760
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1760
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1761 1761
         {
1762 1762
             return $this;
1763 1763
         }
1764 1764
         $this->string($message, $fieldName);
1765
-        if ( mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8' )
1765
+        if (mb_detect_encoding($this->value, 'UTF-8', true) !== 'UTF-8')
1766 1766
         {
1767 1767
             $message = $message
1768 1768
                 ?: sprintf(
@@ -1785,14 +1785,14 @@  discard block
 block discarded – undo
1785 1785
      * @return Assert
1786 1786
      * @throws AssertionFailedException
1787 1787
      */
1788
-    public function ascii(string $message='', string $fieldName='') : Assert
1788
+    public function ascii(string $message = '', string $fieldName = '') : Assert
1789 1789
     {
1790
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1790
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1791 1791
         {
1792 1792
             return $this;
1793 1793
         }
1794 1794
         $this->string($message, $fieldName);
1795
-        if ( ! preg_match('/^[ -~]+$/', $this->value) )
1795
+        if ( ! preg_match('/^[ -~]+$/', $this->value))
1796 1796
         {
1797 1797
             $message = $message
1798 1798
                 ?: sprintf(
@@ -1816,14 +1816,14 @@  discard block
 block discarded – undo
1816 1816
      * @return Assert
1817 1817
      * @throws AssertionFailedException
1818 1818
      */
1819
-    public function keyIsset($key, string $message='', string $fieldName='') : Assert
1819
+    public function keyIsset($key, string $message = '', string $fieldName = '') : Assert
1820 1820
     {
1821
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1821
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1822 1822
         {
1823 1823
             return $this;
1824 1824
         }
1825 1825
         $this->isArrayAccessible($message, $fieldName);
1826
-        if ( !isset( $this->value[$key] ) )
1826
+        if ( ! isset($this->value[ $key ]))
1827 1827
         {
1828 1828
             $message = $message ?: $this->overrideError;
1829 1829
             $message = sprintf(
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
                 $this->stringify($key)
1832 1832
             );
1833 1833
 
1834
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, ['key' => $key]);
1834
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_KEY_ISSET, $fieldName, [ 'key' => $key ]);
1835 1835
         }
1836 1836
 
1837 1837
         return $this;
@@ -1847,14 +1847,14 @@  discard block
 block discarded – undo
1847 1847
      * @return Assert
1848 1848
      * @throws AssertionFailedException
1849 1849
      */
1850
-    public function notEmptyKey($key, string $message='', string $fieldName='') : Assert
1850
+    public function notEmptyKey($key, string $message = '', string $fieldName = '') : Assert
1851 1851
     {
1852
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1852
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1853 1853
         {
1854 1854
             return $this;
1855 1855
         }
1856 1856
         $this->keyIsset($key, $message, $fieldName);
1857
-        (new Assert($this->value[$key]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1857
+        (new Assert($this->value[ $key ]))->setExceptionClass($this->exceptionClass)->notEmpty($message, $fieldName);
1858 1858
 
1859 1859
         return $this;
1860 1860
     }
@@ -1867,13 +1867,13 @@  discard block
 block discarded – undo
1867 1867
      * @return Assert
1868 1868
      * @throws AssertionFailedException
1869 1869
      */
1870
-    public function notBlank(string $message='', string $fieldName='') : Assert
1870
+    public function notBlank(string $message = '', string $fieldName = '') : Assert
1871 1871
     {
1872
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1872
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1873 1873
         {
1874 1874
             return $this;
1875 1875
         }
1876
-        if ( false === $this->value || ( empty( $this->value ) && '0' != $this->value ) )
1876
+        if (false === $this->value || (empty($this->value) && '0' != $this->value))
1877 1877
         {
1878 1878
             $message = $message ?: $this->overrideError;
1879 1879
             $message = sprintf(
@@ -1896,13 +1896,13 @@  discard block
 block discarded – undo
1896 1896
      * @return Assert
1897 1897
      * @throws AssertionFailedException
1898 1898
      */
1899
-    public function isInstanceOf(string $className, string $message='', string $fieldName='') : Assert
1899
+    public function isInstanceOf(string $className, string $message = '', string $fieldName = '') : Assert
1900 1900
     {
1901
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1901
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1902 1902
         {
1903 1903
             return $this;
1904 1904
         }
1905
-        if ( !( $this->value instanceof $className ) )
1905
+        if ( ! ($this->value instanceof $className))
1906 1906
         {
1907 1907
             $message = $message ?: $this->overrideError;
1908 1908
             $message = sprintf(
@@ -1911,7 +1911,7 @@  discard block
 block discarded – undo
1911 1911
                 $className
1912 1912
             );
1913 1913
 
1914
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, ['class' => $className]);
1914
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1915 1915
         }
1916 1916
 
1917 1917
         return $this;
@@ -1926,13 +1926,13 @@  discard block
 block discarded – undo
1926 1926
      * @return Assert
1927 1927
      * @throws AssertionFailedException
1928 1928
      */
1929
-    public function notIsInstanceOf(string $className, string $message='', string $fieldName='') : Assert
1929
+    public function notIsInstanceOf(string $className, string $message = '', string $fieldName = '') : Assert
1930 1930
     {
1931
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1931
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1932 1932
         {
1933 1933
             return $this;
1934 1934
         }
1935
-        if ( $this->value instanceof $className )
1935
+        if ($this->value instanceof $className)
1936 1936
         {
1937 1937
             $message = $message ?: $this->overrideError;
1938 1938
             $message = sprintf(
@@ -1941,7 +1941,7 @@  discard block
 block discarded – undo
1941 1941
                 $className
1942 1942
             );
1943 1943
 
1944
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, ['class' => $className]);
1944
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_NOT_INSTANCE_OF, $fieldName, [ 'class' => $className ]);
1945 1945
         }
1946 1946
 
1947 1947
         return $this;
@@ -1956,13 +1956,13 @@  discard block
 block discarded – undo
1956 1956
      * @return Assert
1957 1957
      * @throws AssertionFailedException
1958 1958
      */
1959
-    public function subclassOf(string $className, string $message='', string $fieldName='') : Assert
1959
+    public function subclassOf(string $className, string $message = '', string $fieldName = '') : Assert
1960 1960
     {
1961
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1961
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1962 1962
         {
1963 1963
             return $this;
1964 1964
         }
1965
-        if ( !is_subclass_of($this->value, $className) )
1965
+        if ( ! is_subclass_of($this->value, $className))
1966 1966
         {
1967 1967
             $message = $message ?: $this->overrideError;
1968 1968
             $message = sprintf(
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
                 $className
1972 1972
             );
1973 1973
 
1974
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, ['class' => $className]);
1974
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_SUBCLASS_OF, $fieldName, [ 'class' => $className ]);
1975 1975
         }
1976 1976
 
1977 1977
         return $this;
@@ -1987,14 +1987,14 @@  discard block
 block discarded – undo
1987 1987
      * @return Assert
1988 1988
      * @throws AssertionFailedException
1989 1989
      */
1990
-    public function range(float $minValue, float $maxValue, string $message='', string $fieldName='') : Assert
1990
+    public function range(float $minValue, float $maxValue, string $message = '', string $fieldName = '') : Assert
1991 1991
     {
1992
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
1992
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
1993 1993
         {
1994 1994
             return $this;
1995 1995
         }
1996 1996
         $this->numeric($message, $fieldName);
1997
-        if ( $this->value < $minValue || $this->value > $maxValue )
1997
+        if ($this->value < $minValue || $this->value > $maxValue)
1998 1998
         {
1999 1999
             $message = $message ?: $this->overrideError;
2000 2000
             $message = sprintf(
@@ -2022,14 +2022,14 @@  discard block
 block discarded – undo
2022 2022
      * @return Assert
2023 2023
      * @throws AssertionFailedException
2024 2024
      */
2025
-    public function min(int $minValue, string $message='', string $fieldName='') : Assert
2025
+    public function min(int $minValue, string $message = '', string $fieldName = '') : Assert
2026 2026
     {
2027
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2027
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2028 2028
         {
2029 2029
             return $this;
2030 2030
         }
2031 2031
         $this->numeric($message, $fieldName);
2032
-        if ( $this->value < $minValue )
2032
+        if ($this->value < $minValue)
2033 2033
         {
2034 2034
             $message = $message ?: $this->overrideError;
2035 2035
             $message = sprintf(
@@ -2038,7 +2038,7 @@  discard block
 block discarded – undo
2038 2038
                 $this->stringify($minValue)
2039 2039
             );
2040 2040
 
2041
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, ['min' => $minValue]);
2041
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MIN, $fieldName, [ 'min' => $minValue ]);
2042 2042
         }
2043 2043
 
2044 2044
         return $this;
@@ -2053,14 +2053,14 @@  discard block
 block discarded – undo
2053 2053
      * @return Assert
2054 2054
      * @throws AssertionFailedException
2055 2055
      */
2056
-    public function max(int $maxValue, string $message='', string $fieldName='') : Assert
2056
+    public function max(int $maxValue, string $message = '', string $fieldName = '') : Assert
2057 2057
     {
2058
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2058
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2059 2059
         {
2060 2060
             return $this;
2061 2061
         }
2062 2062
         $this->numeric($message, $fieldName);
2063
-        if ( $this->value > $maxValue )
2063
+        if ($this->value > $maxValue)
2064 2064
         {
2065 2065
             $message = $message ?: $this->overrideError;
2066 2066
             $message = sprintf(
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
                 $this->stringify($maxValue)
2070 2070
             );
2071 2071
 
2072
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, ['max' => $maxValue]);
2072
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_MAX, $fieldName, [ 'max' => $maxValue ]);
2073 2073
         }
2074 2074
 
2075 2075
         return $this;
@@ -2083,15 +2083,15 @@  discard block
 block discarded – undo
2083 2083
      * @return Assert
2084 2084
      * @throws AssertionFailedException
2085 2085
      */
2086
-    public function file(string $message='', string $fieldName='') : Assert
2086
+    public function file(string $message = '', string $fieldName = '') : Assert
2087 2087
     {
2088
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2088
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2089 2089
         {
2090 2090
             return $this;
2091 2091
         }
2092 2092
         $this->string($message, $fieldName);
2093 2093
         $this->notEmpty($message, $fieldName);
2094
-        if ( !is_file($this->value) )
2094
+        if ( ! is_file($this->value))
2095 2095
         {
2096 2096
             $message = $message ?: $this->overrideError;
2097 2097
             $message = sprintf(
@@ -2113,15 +2113,15 @@  discard block
 block discarded – undo
2113 2113
      * @return Assert
2114 2114
      * @throws AssertionFailedException
2115 2115
      */
2116
-    public function fileOrDirectoryExists(string $message='', string $fieldName='') : Assert
2116
+    public function fileOrDirectoryExists(string $message = '', string $fieldName = '') : Assert
2117 2117
     {
2118
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2118
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2119 2119
         {
2120 2120
             return $this;
2121 2121
         }
2122 2122
         $this->string($message, $fieldName);
2123 2123
         $this->notEmpty($message, $fieldName);
2124
-        if ( ! file_exists($this->value) )
2124
+        if ( ! file_exists($this->value))
2125 2125
         {
2126 2126
             $message = $message ?: $this->overrideError;
2127 2127
             $message = sprintf(
@@ -2143,14 +2143,14 @@  discard block
 block discarded – undo
2143 2143
      * @return Assert
2144 2144
      * @throws AssertionFailedException
2145 2145
      */
2146
-    public function directory(string $message='', string $fieldName='') : Assert
2146
+    public function directory(string $message = '', string $fieldName = '') : Assert
2147 2147
     {
2148
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2148
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2149 2149
         {
2150 2150
             return $this;
2151 2151
         }
2152 2152
         $this->string($message, $fieldName);
2153
-        if ( !is_dir($this->value) )
2153
+        if ( ! is_dir($this->value))
2154 2154
         {
2155 2155
             $message = $message ?: $this->overrideError;
2156 2156
             $message = sprintf(
@@ -2172,14 +2172,14 @@  discard block
 block discarded – undo
2172 2172
      * @return Assert
2173 2173
      * @throws AssertionFailedException
2174 2174
      */
2175
-    public function readable(string $message='', string $fieldName='') : Assert
2175
+    public function readable(string $message = '', string $fieldName = '') : Assert
2176 2176
     {
2177
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2177
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2178 2178
         {
2179 2179
             return $this;
2180 2180
         }
2181 2181
         $this->string($message, $fieldName);
2182
-        if ( !is_readable($this->value) )
2182
+        if ( ! is_readable($this->value))
2183 2183
         {
2184 2184
             $message = $message ?: $this->overrideError;
2185 2185
             $message = sprintf(
@@ -2201,14 +2201,14 @@  discard block
 block discarded – undo
2201 2201
      * @return Assert
2202 2202
      * @throws AssertionFailedException
2203 2203
      */
2204
-    public function writeable(string $message='', string $fieldName='') : Assert
2204
+    public function writeable(string $message = '', string $fieldName = '') : Assert
2205 2205
     {
2206
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2206
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2207 2207
         {
2208 2208
             return $this;
2209 2209
         }
2210 2210
         $this->string($message, $fieldName);
2211
-        if ( !is_writeable($this->value) )
2211
+        if ( ! is_writeable($this->value))
2212 2212
         {
2213 2213
             $message = $message ?: $this->overrideError;
2214 2214
             $message = sprintf(
@@ -2230,14 +2230,14 @@  discard block
 block discarded – undo
2230 2230
      * @return Assert
2231 2231
      * @throws AssertionFailedException
2232 2232
      */
2233
-    public function email(string $message='', string $fieldName='') : Assert
2233
+    public function email(string $message = '', string $fieldName = '') : Assert
2234 2234
     {
2235
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2235
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2236 2236
         {
2237 2237
             return $this;
2238 2238
         }
2239 2239
         $this->string($message, $fieldName);
2240
-        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL) )
2240
+        if ( ! filter_var($this->value, FILTER_VALIDATE_EMAIL))
2241 2241
         {
2242 2242
             $message = $message ?: $this->overrideError;
2243 2243
             $message = sprintf(
@@ -2251,7 +2251,7 @@  discard block
 block discarded – undo
2251 2251
         {
2252 2252
             $host = substr($this->value, strpos($this->value, '@') + 1);
2253 2253
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
2254
-            if ( version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false )
2254
+            if (version_compare(PHP_VERSION, '5.3.3', '<') && strpos($host, '.') === false)
2255 2255
             {
2256 2256
                 $message = $message ?: $this->overrideError;
2257 2257
                 $message = sprintf(
@@ -2273,9 +2273,9 @@  discard block
 block discarded – undo
2273 2273
      * @return Assert
2274 2274
      * @throws AssertionFailedException
2275 2275
      */
2276
-    public function emailPrefix(string $message='', string $fieldName='') : Assert
2276
+    public function emailPrefix(string $message = '', string $fieldName = '') : Assert
2277 2277
     {
2278
-        $this->value($this->value . '@example.com');
2278
+        $this->value($this->value.'@example.com');
2279 2279
 
2280 2280
         return $this->email($message, $fieldName);
2281 2281
     }
@@ -2294,14 +2294,14 @@  discard block
 block discarded – undo
2294 2294
      * @link https://github.com/symfony/Validator/blob/master/Constraints/UrlValidator.php
2295 2295
      * @link https://github.com/symfony/Validator/blob/master/Constraints/Url.php
2296 2296
      */
2297
-    public function url(string $message='', string $fieldName='') : Assert
2297
+    public function url(string $message = '', string $fieldName = '') : Assert
2298 2298
     {
2299
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2299
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2300 2300
         {
2301 2301
             return $this;
2302 2302
         }
2303 2303
         $this->string($message, $fieldName);
2304
-        $protocols = ['http', 'https'];
2304
+        $protocols = [ 'http', 'https' ];
2305 2305
         $pattern   = '~^
2306 2306
             (%s)://                                 # protocol
2307 2307
             (
@@ -2316,8 +2316,8 @@  discard block
 block discarded – undo
2316 2316
             (:[0-9]+)?                              # a port (optional)
2317 2317
             (/?|/\S+)                               # a /, nothing or a / with something
2318 2318
         $~ixu';
2319
-        $pattern   = sprintf($pattern, implode('|', $protocols));
2320
-        if ( !preg_match($pattern, $this->value) )
2319
+        $pattern = sprintf($pattern, implode('|', $protocols));
2320
+        if ( ! preg_match($pattern, $this->value))
2321 2321
         {
2322 2322
             $message = $message ?: $this->overrideError;
2323 2323
             $message = sprintf(
@@ -2342,15 +2342,15 @@  discard block
 block discarded – undo
2342 2342
      * @throws AssertionFailedException
2343 2343
      *
2344 2344
      */
2345
-    public function domainName(string $message='', string $fieldName='') : Assert
2345
+    public function domainName(string $message = '', string $fieldName = '') : Assert
2346 2346
     {
2347
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2347
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2348 2348
         {
2349 2349
             return $this;
2350 2350
         }
2351 2351
         $this->string($message, $fieldName);
2352
-        $pattern   = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2353
-        if ( ! preg_match($pattern, $this->value) )
2352
+        $pattern = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}$/';
2353
+        if ( ! preg_match($pattern, $this->value))
2354 2354
         {
2355 2355
             $message = $message ?: $this->overrideError;
2356 2356
             $message = sprintf(
@@ -2372,9 +2372,9 @@  discard block
 block discarded – undo
2372 2372
      * @return Assert
2373 2373
      * @throws AssertionFailedException
2374 2374
      */
2375
-    public function ausMobile(string $message='', string $fieldName='') : Assert
2375
+    public function ausMobile(string $message = '', string $fieldName = '') : Assert
2376 2376
     {
2377
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2377
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2378 2378
         {
2379 2379
             return $this;
2380 2380
         }
@@ -2382,7 +2382,7 @@  discard block
 block discarded – undo
2382 2382
         {
2383 2383
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2384 2384
         }
2385
-        catch ( AssertionFailedException $e )
2385
+        catch (AssertionFailedException $e)
2386 2386
         {
2387 2387
             $message = $message ?: $this->overrideError;
2388 2388
             $message = sprintf(
@@ -2405,9 +2405,9 @@  discard block
 block discarded – undo
2405 2405
      * @return Assert
2406 2406
      * @throws AssertionFailedException
2407 2407
      */
2408
-    public function alnum(string $message='', string $fieldName='') : Assert
2408
+    public function alnum(string $message = '', string $fieldName = '') : Assert
2409 2409
     {
2410
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2410
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2411 2411
         {
2412 2412
             return $this;
2413 2413
         }
@@ -2438,13 +2438,13 @@  discard block
 block discarded – undo
2438 2438
      * @return Assert
2439 2439
      * @throws AssertionFailedException
2440 2440
      */
2441
-    public function true(string $message='', string $fieldName='') : Assert
2441
+    public function true(string $message = '', string $fieldName = '') : Assert
2442 2442
     {
2443
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2443
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2444 2444
         {
2445 2445
             return $this;
2446 2446
         }
2447
-        if ( $this->value !== true )
2447
+        if ($this->value !== true)
2448 2448
         {
2449 2449
             $message = $message ?: $this->overrideError;
2450 2450
             $message = sprintf(
@@ -2466,13 +2466,13 @@  discard block
 block discarded – undo
2466 2466
      * @return Assert
2467 2467
      * @throws AssertionFailedException
2468 2468
      */
2469
-    public function truthy(string $message='', string $fieldName='') : Assert
2469
+    public function truthy(string $message = '', string $fieldName = '') : Assert
2470 2470
     {
2471
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2471
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2472 2472
         {
2473 2473
             return $this;
2474 2474
         }
2475
-        if ( ! $this->value )
2475
+        if ( ! $this->value)
2476 2476
         {
2477 2477
             $message = $message ?: $this->overrideError;
2478 2478
             $message = sprintf(
@@ -2494,13 +2494,13 @@  discard block
 block discarded – undo
2494 2494
      * @return Assert
2495 2495
      * @throws AssertionFailedException
2496 2496
      */
2497
-    public function false(string $message='', string $fieldName='') : Assert
2497
+    public function false(string $message = '', string $fieldName = '') : Assert
2498 2498
     {
2499
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2499
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2500 2500
         {
2501 2501
             return $this;
2502 2502
         }
2503
-        if ( $this->value !== false )
2503
+        if ($this->value !== false)
2504 2504
         {
2505 2505
             $message = $message ?: $this->overrideError;
2506 2506
             $message = sprintf(
@@ -2522,13 +2522,13 @@  discard block
 block discarded – undo
2522 2522
      * @return Assert
2523 2523
      * @throws AssertionFailedException
2524 2524
      */
2525
-    public function notFalse(string $message='', string $fieldName='') : Assert
2525
+    public function notFalse(string $message = '', string $fieldName = '') : Assert
2526 2526
     {
2527
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2527
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2528 2528
         {
2529 2529
             return $this;
2530 2530
         }
2531
-        if ( $this->value === false )
2531
+        if ($this->value === false)
2532 2532
         {
2533 2533
             $message = $message ?: $this->overrideError;
2534 2534
             $message = sprintf(
@@ -2550,13 +2550,13 @@  discard block
 block discarded – undo
2550 2550
      * @return Assert
2551 2551
      * @throws AssertionFailedException
2552 2552
      */
2553
-    public function classExists(string $message='', string $fieldName='') : Assert
2553
+    public function classExists(string $message = '', string $fieldName = '') : Assert
2554 2554
     {
2555
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2555
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2556 2556
         {
2557 2557
             return $this;
2558 2558
         }
2559
-        if ( !class_exists($this->value) )
2559
+        if ( ! class_exists($this->value))
2560 2560
         {
2561 2561
             $message = $message ?: $this->overrideError;
2562 2562
             $message = sprintf(
@@ -2578,14 +2578,14 @@  discard block
 block discarded – undo
2578 2578
      * @throws AssertionFailedException
2579 2579
      * @throws \ReflectionException
2580 2580
      */
2581
-    public function implementsInterface(string $interfaceName, string $message='', string $fieldName='') : Assert
2581
+    public function implementsInterface(string $interfaceName, string $message = '', string $fieldName = '') : Assert
2582 2582
     {
2583
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2583
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2584 2584
         {
2585 2585
             return $this;
2586 2586
         }
2587 2587
         $reflection = new \ReflectionClass($this->value);
2588
-        if ( !$reflection->implementsInterface($interfaceName) )
2588
+        if ( ! $reflection->implementsInterface($interfaceName))
2589 2589
         {
2590 2590
             $message = $message ?: $this->overrideError;
2591 2591
             $message = sprintf(
@@ -2594,7 +2594,7 @@  discard block
 block discarded – undo
2594 2594
                 $this->stringify($interfaceName)
2595 2595
             );
2596 2596
 
2597
-            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, ['interface' => $interfaceName]);
2597
+            throw $this->createException($message, self::INTERFACE_NOT_IMPLEMENTED, $fieldName, [ 'interface' => $interfaceName ]);
2598 2598
         }
2599 2599
 
2600 2600
         return $this;
@@ -2614,13 +2614,13 @@  discard block
 block discarded – undo
2614 2614
      * @return Assert
2615 2615
      * @throws AssertionFailedException
2616 2616
      */
2617
-    public function isJsonString(string $message='', string $fieldName='') : Assert
2617
+    public function isJsonString(string $message = '', string $fieldName = '') : Assert
2618 2618
     {
2619
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2619
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2620 2620
         {
2621 2621
             return $this;
2622 2622
         }
2623
-        if ( null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error() )
2623
+        if (null === json_decode($this->value) && JSON_ERROR_NONE !== json_last_error())
2624 2624
         {
2625 2625
             $message = $message ?: $this->overrideError;
2626 2626
             $message = sprintf(
@@ -2644,18 +2644,18 @@  discard block
 block discarded – undo
2644 2644
      * @return Assert
2645 2645
      * @throws AssertionFailedException
2646 2646
      */
2647
-    public function uuid(string $message='', string $fieldName='') : Assert
2647
+    public function uuid(string $message = '', string $fieldName = '') : Assert
2648 2648
     {
2649
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2649
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2650 2650
         {
2651 2651
             return $this;
2652 2652
         }
2653
-        $this->value = str_replace(['urn:', 'uuid:', '{', '}'], '', $this->value);
2654
-        if ( $this->value === '00000000-0000-0000-0000-000000000000' )
2653
+        $this->value = str_replace([ 'urn:', 'uuid:', '{', '}' ], '', $this->value);
2654
+        if ($this->value === '00000000-0000-0000-0000-000000000000')
2655 2655
         {
2656 2656
             return $this;
2657 2657
         }
2658
-        if ( !preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $this->value) )
2658
+        if ( ! preg_match('/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/', $this->value))
2659 2659
         {
2660 2660
             $message = $message ?: $this->overrideError;
2661 2661
             $message = sprintf(
@@ -2684,13 +2684,13 @@  discard block
 block discarded – undo
2684 2684
      * @return Assert
2685 2685
      * @throws AssertionFailedException
2686 2686
      */
2687
-    public function samAccountName(string $message='', string $fieldName='') : Assert
2687
+    public function samAccountName(string $message = '', string $fieldName = '') : Assert
2688 2688
     {
2689
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2689
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2690 2690
         {
2691 2691
             return $this;
2692 2692
         }
2693
-        if ( !preg_match('/^([a-z0-9]{4,20})$/', $this->value) )
2693
+        if ( ! preg_match('/^([a-z0-9]{4,20})$/', $this->value))
2694 2694
         {
2695 2695
             $message = $message ?: $this->overrideError;
2696 2696
             $message = sprintf(
@@ -2712,9 +2712,9 @@  discard block
 block discarded – undo
2712 2712
      * @return Assert
2713 2713
      * @throws AssertionFailedException
2714 2714
      */
2715
-    public function userPrincipalName(string $message='', string $fieldName='') : Assert
2715
+    public function userPrincipalName(string $message = '', string $fieldName = '') : Assert
2716 2716
     {
2717
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2717
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2718 2718
         {
2719 2719
             return $this;
2720 2720
         }
@@ -2747,13 +2747,13 @@  discard block
 block discarded – undo
2747 2747
      * @return Assert
2748 2748
      * @throws AssertionFailedException
2749 2749
      */
2750
-    public function isni(string $message='', string $fieldName='')
2750
+    public function isni(string $message = '', string $fieldName = '')
2751 2751
     {
2752
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2752
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2753 2753
         {
2754 2754
             return $this;
2755 2755
         }
2756
-        if ( !preg_match('/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]{1}$/', $this->value) )
2756
+        if ( ! preg_match('/^[0-9]{4}-[0-9]{4}-[0-9]{4}-[0-9]{3}[0-9X]{1}$/', $this->value))
2757 2757
         {
2758 2758
             $message = $message ?: $this->overrideError;
2759 2759
             $message = sprintf(
@@ -2776,13 +2776,13 @@  discard block
 block discarded – undo
2776 2776
      * @return Assert
2777 2777
      * @throws AssertionFailedException
2778 2778
      */
2779
-    public function count(int $count, string $message='', string $fieldName='') : Assert
2779
+    public function count(int $count, string $message = '', string $fieldName = '') : Assert
2780 2780
     {
2781
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2781
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2782 2782
         {
2783 2783
             return $this;
2784 2784
         }
2785
-        if ( $count !== count($this->value) )
2785
+        if ($count !== count($this->value))
2786 2786
         {
2787 2787
             $message = $message ?: $this->overrideError;
2788 2788
             $message = sprintf(
@@ -2791,7 +2791,7 @@  discard block
 block discarded – undo
2791 2791
                 $this->stringify($count)
2792 2792
             );
2793 2793
 
2794
-            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, ['count' => $count]);
2794
+            throw $this->createException($message, $this->overrideCode ?: self::INVALID_COUNT, $fieldName, [ 'count' => $count ]);
2795 2795
         }
2796 2796
 
2797 2797
         return $this;
@@ -2805,25 +2805,25 @@  discard block
 block discarded – undo
2805 2805
      */
2806 2806
     protected function doAllOrNullOr($func, $args) : bool
2807 2807
     {
2808
-        if ( $this->nullOr && is_null($this->value) )
2808
+        if ($this->nullOr && is_null($this->value))
2809 2809
         {
2810 2810
             return true;
2811 2811
         }
2812
-        if ( $this->emptyOr && empty($this->value) )
2812
+        if ($this->emptyOr && empty($this->value))
2813 2813
         {
2814 2814
             return true;
2815 2815
         }
2816
-        if ( $this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable() )
2816
+        if ($this->all && (new Assert($this->value))->setExceptionClass($this->exceptionClass)->isTraversable())
2817 2817
         {
2818
-            foreach ( $this->value as $idx => $value )
2818
+            foreach ($this->value as $idx => $value)
2819 2819
             {
2820 2820
                 $object = (new Assert($value))->setExceptionClass($this->exceptionClass);
2821
-                call_user_func_array([$object, $func], $args);
2821
+                call_user_func_array([ $object, $func ], $args);
2822 2822
             }
2823 2823
             return true;
2824 2824
         }
2825 2825
 
2826
-        return ( $this->nullOr && is_null($this->value) ) || ( $this->emptyOr && empty($this->value) ) ? true : false;
2826
+        return ($this->nullOr && is_null($this->value)) || ($this->emptyOr && empty($this->value)) ? true : false;
2827 2827
     }
2828 2828
 
2829 2829
     /**
@@ -2835,14 +2835,14 @@  discard block
 block discarded – undo
2835 2835
      * @return Assert
2836 2836
      * @throws AssertionFailedException
2837 2837
      */
2838
-    public function choicesNotEmpty(array $choices, string $message='', string $fieldName='') : Assert
2838
+    public function choicesNotEmpty(array $choices, string $message = '', string $fieldName = '') : Assert
2839 2839
     {
2840
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2840
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2841 2841
         {
2842 2842
             return $this;
2843 2843
         }
2844 2844
         $this->notEmpty($message, $fieldName);
2845
-        foreach ( $choices as $choice )
2845
+        foreach ($choices as $choice)
2846 2846
         {
2847 2847
             $this->notEmptyKey($choice, $message, $fieldName);
2848 2848
         }
@@ -2859,14 +2859,14 @@  discard block
 block discarded – undo
2859 2859
      * @returns Assert
2860 2860
      * @throws AssertionFailedException
2861 2861
      */
2862
-    public function methodExists($object, string $message='', string $fieldName='') : Assert
2862
+    public function methodExists($object, string $message = '', string $fieldName = '') : Assert
2863 2863
     {
2864
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2864
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2865 2865
         {
2866 2866
             return $this;
2867 2867
         }
2868 2868
         (new Assert($object))->setExceptionClass($this->exceptionClass)->isObject($message, $fieldName);
2869
-        if ( !method_exists($object, $this->value) )
2869
+        if ( ! method_exists($object, $this->value))
2870 2870
         {
2871 2871
             $message = $message ?: $this->overrideError;
2872 2872
             $message = sprintf(
@@ -2888,13 +2888,13 @@  discard block
 block discarded – undo
2888 2888
      * @return Assert
2889 2889
      * @throws AssertionFailedException
2890 2890
      */
2891
-    public function isObject(string $message='', string $fieldName='') : Assert
2891
+    public function isObject(string $message = '', string $fieldName = '') : Assert
2892 2892
     {
2893
-        if ( $this->doAllOrNullOr(__FUNCTION__, func_get_args()) )
2893
+        if ($this->doAllOrNullOr(__FUNCTION__, func_get_args()))
2894 2894
         {
2895 2895
             return $this;
2896 2896
         }
2897
-        if ( !is_object($this->value) )
2897
+        if ( ! is_object($this->value))
2898 2898
         {
2899 2899
             $message = $message ?: $this->overrideError;
2900 2900
             $message = sprintf(
@@ -2916,33 +2916,33 @@  discard block
 block discarded – undo
2916 2916
      */
2917 2917
     private function stringify($value) : string
2918 2918
     {
2919
-        if ( is_bool($value) )
2919
+        if (is_bool($value))
2920 2920
         {
2921 2921
             return $value ? '<TRUE>' : '<FALSE>';
2922 2922
         }
2923
-        if ( is_scalar($value) )
2923
+        if (is_scalar($value))
2924 2924
         {
2925 2925
             $val = (string)$value;
2926
-            if ( strlen($val) > 100 )
2926
+            if (strlen($val) > 100)
2927 2927
             {
2928
-                $val = substr($val, 0, 97) . '...';
2928
+                $val = substr($val, 0, 97).'...';
2929 2929
             }
2930 2930
 
2931 2931
             return $val;
2932 2932
         }
2933
-        if ( is_array($value) )
2933
+        if (is_array($value))
2934 2934
         {
2935 2935
             return '<ARRAY>';
2936 2936
         }
2937
-        if ( is_object($value) )
2937
+        if (is_object($value))
2938 2938
         {
2939 2939
             return get_class($value);
2940 2940
         }
2941
-        if ( is_resource($value) )
2941
+        if (is_resource($value))
2942 2942
         {
2943 2943
             return '<RESOURCE>';
2944 2944
         }
2945
-        if ( $value === null )
2945
+        if ($value === null)
2946 2946
         {
2947 2947
             return '<NULL>';
2948 2948
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -10 removed lines patch added patch discarded remove patch
@@ -158,8 +158,7 @@  discard block
 block discarded – undo
158 158
             try
159 159
             {
160 160
                 $validator->__invoke();
161
-            }
162
-            catch ( AssertionFailedException $e )
161
+            } catch ( AssertionFailedException $e )
163 162
             {
164 163
                 $errors[$fieldName]     = $e->getMessage();
165 164
             }
@@ -2246,8 +2245,7 @@  discard block
 block discarded – undo
2246 2245
             );
2247 2246
 
2248 2247
             throw $this->createException($message, $this->overrideCode ?: self::INVALID_EMAIL, $fieldName);
2249
-        }
2250
-        else
2248
+        } else
2251 2249
         {
2252 2250
             $host = substr($this->value, strpos($this->value, '@') + 1);
2253 2251
             // Likely not a FQDN, bug in PHP FILTER_VALIDATE_EMAIL prior to PHP 5.3.3
@@ -2381,8 +2379,7 @@  discard block
 block discarded – undo
2381 2379
         try
2382 2380
         {
2383 2381
             $this->regex('/^04[0-9]{8})$/', $message, $fieldName);
2384
-        }
2385
-        catch ( AssertionFailedException $e )
2382
+        } catch ( AssertionFailedException $e )
2386 2383
         {
2387 2384
             $message = $message ?: $this->overrideError;
2388 2385
             $message = sprintf(
@@ -2414,8 +2411,7 @@  discard block
 block discarded – undo
2414 2411
         try
2415 2412
         {
2416 2413
             $this->regex('(^([a-zA-Z]{1}[a-zA-Z0-9]*)$)', $message, $fieldName);
2417
-        }
2418
-        catch (AssertionFailedException $e)
2414
+        } catch (AssertionFailedException $e)
2419 2415
         {
2420 2416
             $message = $message ?: $this->overrideError;
2421 2417
             $message = sprintf(
@@ -2721,8 +2717,7 @@  discard block
 block discarded – undo
2721 2717
         try
2722 2718
         {
2723 2719
             $this->email($message, $fieldName);
2724
-        }
2725
-        catch (AssertionFailedException $e)
2720
+        } catch (AssertionFailedException $e)
2726 2721
         {
2727 2722
             $message = $message ?: $this->overrideError;
2728 2723
             $message = sprintf(
Please login to merge, or discard this patch.
src/functions.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
  * @param string $level
32 32
  * @return Assert
33 33
  */
34
-function Assert($value, string $fieldName='', int $code=0, string $error='', string $level=Assert::WARNING)
34
+function Assert($value, string $fieldName = '', int $code = 0, string $error = '', string $level = Assert::WARNING)
35 35
 {
36 36
     $assert = new Assert($value);
37
-    if ( $fieldName )
37
+    if ($fieldName)
38 38
     {
39 39
         $assert->fieldName($fieldName);
40 40
     }
41
-    if ( $code )
41
+    if ($code)
42 42
     {
43 43
         $assert->code($code);
44 44
     }
45
-    if ( $error )
45
+    if ($error)
46 46
     {
47 47
         $assert->error($error);
48 48
     }
49
-    if ( $level )
49
+    if ($level)
50 50
     {
51 51
         $assert->level($level);
52 52
     }
@@ -64,22 +64,22 @@  discard block
 block discarded – undo
64 64
  * @param string $level
65 65
  * @return Assert
66 66
  */
67
-function Validate($value, string $fieldName='', int $code=0, string $error='', string $level=Assert::WARNING)
67
+function Validate($value, string $fieldName = '', int $code = 0, string $error = '', string $level = Assert::WARNING)
68 68
 {
69 69
     $assert = new Assert($value);
70
-    if ( $fieldName )
70
+    if ($fieldName)
71 71
     {
72 72
         $assert->fieldName($fieldName);
73 73
     }
74
-    if ( $code )
74
+    if ($code)
75 75
     {
76 76
         $assert->code($code);
77 77
     }
78
-    if ( $error )
78
+    if ($error)
79 79
     {
80 80
         $assert->error($error);
81 81
     }
82
-    if ( $level )
82
+    if ($level)
83 83
     {
84 84
         $assert->level($level);
85 85
     }
Please login to merge, or discard this patch.
src/AssertionFailedException.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php declare(strict_types=1);
1
+<?php declare(strict_types = 1);
2 2
 
3 3
 namespace Terah\Assert;
4 4
 
@@ -41,7 +41,7 @@  discard block
 block discarded – undo
41 41
      * @param string $level
42 42
      * @param string $propertyPath
43 43
      */
44
-    public function __construct(string $message, int $code, string $fieldName='', $value='', array $constraints=[], string $level='critical', string $propertyPath='')
44
+    public function __construct(string $message, int $code, string $fieldName = '', $value = '', array $constraints = [ ], string $level = 'critical', string $propertyPath = '')
45 45
     {
46 46
         parent::__construct($message, $code);
47 47
         $this->fieldName        = $fieldName;
@@ -49,10 +49,10 @@  discard block
 block discarded – undo
49 49
         $this->constraints      = $constraints;
50 50
         $this->level            = $level;
51 51
         $this->propertyPath     = $propertyPath;
52
-        foreach ( $this->getTrace() as $point )
52
+        foreach ($this->getTrace() as $point)
53 53
         {
54
-            $class = $point['class'] ??0?: '';
55
-            if ( $class !== Assert::class )
54
+            $class = $point[ 'class' ] ??0 ?: '';
55
+            if ($class !== Assert::class)
56 56
             {
57 57
                 $this->location = (object)$point;
58 58
 
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      */
123 123
     public function getPropertyPathAndCallingLocation() : string
124 124
     {
125
-        return $this->getPropertyPath() . ' in ' . $this->getCallingFileAndLine();
125
+        return $this->getPropertyPath().' in '.$this->getCallingFileAndLine();
126 126
     }
127 127
 
128 128
     /**
@@ -133,15 +133,15 @@  discard block
 block discarded – undo
133 133
      */
134 134
     protected function getCallingFileAndLine() : string
135 135
     {
136
-        foreach ( $this->getTrace() as $trace )
136
+        foreach ($this->getTrace() as $trace)
137 137
         {
138 138
             $trace = (object)$trace;
139
-            if ( empty($trace->file) )
139
+            if (empty($trace->file))
140 140
             {
141 141
                 continue;
142 142
             }
143 143
             $file = static::beforeLast('.php', static::afterLast('/', $trace->file));
144
-            if ( in_array($file, ['AssertionChain', 'Assertion']) )
144
+            if (in_array($file, [ 'AssertionChain', 'Assertion' ]))
145 145
             {
146 146
                 continue;
147 147
             }
@@ -168,9 +168,9 @@  discard block
 block discarded – undo
168 168
      * @param bool $returnOriginal
169 169
      * @return string
170 170
      */
171
-    public static function afterLast(string $needle, string $haystack, bool $returnOriginal=false) : string
171
+    public static function afterLast(string $needle, string $haystack, bool $returnOriginal = false) : string
172 172
     {
173
-        if ( static::strrevpos($haystack, $needle) !== -1 )
173
+        if (static::strrevpos($haystack, $needle) !== -1)
174 174
         {
175 175
             return mb_substr($haystack, static::strrevpos($haystack, $needle) + mb_strlen($needle));
176 176
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public static function beforeLast(string $needle, string $haystack) : string
199 199
     {
200
-        $position   = static::strrevpos($haystack, $needle);
200
+        $position = static::strrevpos($haystack, $needle);
201 201
 
202 202
         return $position === -1 ? '' : mb_substr($haystack, 0, static::strrevpos($haystack, $needle));
203 203
     }
Please login to merge, or discard this patch.