@@ -18,9 +18,9 @@ |
||
18 | 18 | |
19 | 19 | public function __call($method, $bar) |
20 | 20 | { |
21 | - return $this->container->$method( |
|
22 | - $this->resourceName |
|
23 | - ); |
|
21 | + return $this->container->$method( |
|
22 | + $this->resourceName |
|
23 | + ); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | public function resourceName() |
@@ -47,7 +47,7 @@ |
||
47 | 47 | |
48 | 48 | public function asArray() : array |
49 | 49 | { |
50 | - return $this->rule; |
|
50 | + return $this->rule; |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | public function isValid() |
@@ -15,7 +15,6 @@ |
||
15 | 15 | use PHPUnit_Framework_TestCase; |
16 | 16 | use Resources\BirthDay; |
17 | 17 | use Sensorario\Resources\Helpers\JsonExporter; |
18 | -use Sensorario\Resources\Resources\Resource; |
|
19 | 18 | use Sensorario\Resources\Validators\ResourcesValidator; |
20 | 19 | |
21 | 20 | final class JsonExporterTest extends PHPUnit_Framework_TestCase |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ], |
109 | 109 | ]); |
110 | 110 | |
111 | - $this->assertEquals( [ |
|
111 | + $this->assertEquals([ |
|
112 | 112 | 'foo', |
113 | 113 | 'bar', |
114 | 114 | ], |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | ], |
142 | 142 | ]); |
143 | 143 | |
144 | - $this->assertEquals( [ |
|
144 | + $this->assertEquals([ |
|
145 | 145 | 'foo' => [ |
146 | 146 | 'set' => [ |
147 | 147 | 'equals_to' => 'bar', |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function testInvalidTypeIsNotAllowed() |
48 | 48 | { |
49 | 49 | $rule = Rule::fromArray([ |
50 | - 'foo' => [ ] |
|
50 | + 'foo' => [] |
|
51 | 51 | ]); |
52 | 52 | |
53 | 53 | $rule->ensureRuleNameIsValid(); |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | public function testCheckFunctionReturnRuleValidityAsBoolean() |
57 | 57 | { |
58 | 58 | $rule = Rule::fromArray([ |
59 | - 'foo' => [ ] |
|
59 | + 'foo' => [] |
|
60 | 60 | ]); |
61 | 61 | |
62 | 62 | $this->assertSame( |
@@ -305,7 +305,7 @@ discard block |
||
305 | 305 | 'resources' => [ |
306 | 306 | 'bar' => [ |
307 | 307 | 'constraints' => [ |
308 | - 'allowed' => [ 'allowed_property_name' ], |
|
308 | + 'allowed' => ['allowed_property_name'], |
|
309 | 309 | ] |
310 | 310 | ], |
311 | 311 | ], |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | ); |
315 | 315 | |
316 | 316 | $this->assertEquals( |
317 | - [ 'allowed_property_name' ], |
|
317 | + ['allowed_property_name'], |
|
318 | 318 | $resource->allowed('bar') |
319 | 319 | ); |
320 | 320 | } |
@@ -356,19 +356,19 @@ discard block |
||
356 | 356 | 'resources' => [ |
357 | 357 | 'foo' => [ |
358 | 358 | 'constraints' => [ |
359 | - 'allowed' => [ 'allowed_property_name' ], |
|
359 | + 'allowed' => ['allowed_property_name'], |
|
360 | 360 | ] |
361 | 361 | ], |
362 | 362 | 'unused_resource' => [ |
363 | 363 | 'constraints' => [ |
364 | - 'allowed' => [ 'bar' ], |
|
364 | + 'allowed' => ['bar'], |
|
365 | 365 | ] |
366 | 366 | ], |
367 | 367 | ], |
368 | 368 | ]); |
369 | 369 | |
370 | 370 | $this->assertEquals( |
371 | - [ 'allowed_property_name' ], |
|
371 | + ['allowed_property_name'], |
|
372 | 372 | $container->allowed('foo') |
373 | 373 | ); |
374 | 374 | } |
@@ -420,14 +420,14 @@ discard block |
||
420 | 420 | 'resources' => [ |
421 | 421 | 'foo' => [ |
422 | 422 | 'constraints' => [ |
423 | - 'mandatory' => [ 'mandatory_property' ], |
|
423 | + 'mandatory' => ['mandatory_property'], |
|
424 | 424 | ] |
425 | 425 | ], |
426 | 426 | ], |
427 | 427 | ]); |
428 | 428 | |
429 | 429 | $this->assertEquals( |
430 | - [ 'mandatory_property' ], |
|
430 | + ['mandatory_property'], |
|
431 | 431 | $container->allowed('foo') |
432 | 432 | ); |
433 | 433 | } |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | 'resources' => [ |
441 | 441 | 'foo' => [ |
442 | 442 | 'constraints' => [ |
443 | - 'mandatory' => [ 'date' ], |
|
444 | - 'rules' => [ 'date' => [ 'object' => 'DateTime' ] ], |
|
443 | + 'mandatory' => ['date'], |
|
444 | + 'rules' => ['date' => ['object' => 'DateTime']], |
|
445 | 445 | ] |
446 | 446 | ], |
447 | 447 | ], |
@@ -467,7 +467,7 @@ discard block |
||
467 | 467 | 'resources' => [ |
468 | 468 | 'foo' => [ |
469 | 469 | 'constraints' => [ |
470 | - 'allowed' => [ 'user_type' ], |
|
470 | + 'allowed' => ['user_type'], |
|
471 | 471 | 'allowedValues' => [ |
472 | 472 | 'user_type' => [ |
473 | 473 | 4, |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | ]) |
481 | 481 | ); |
482 | 482 | |
483 | - $properties = [ 'user_type' => 3 ]; |
|
483 | + $properties = ['user_type' => 3]; |
|
484 | 484 | |
485 | 485 | Resource::box( |
486 | 486 | $properties, |
@@ -569,7 +569,7 @@ discard block |
||
569 | 569 | ); |
570 | 570 | |
571 | 571 | Resource::box( |
572 | - [ 'age' => 2 ], |
|
572 | + ['age' => 2], |
|
573 | 573 | $configurator |
574 | 574 | ); |
575 | 575 | } |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | 'first-email', |
670 | 670 | ], |
671 | 671 | 'rules' => [ |
672 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
672 | + 'first-email' => ['custom-validator' => 'email'], |
|
673 | 673 | ], |
674 | 674 | ] |
675 | 675 | ], |
@@ -696,8 +696,8 @@ discard block |
||
696 | 696 | 'resources' => [ |
697 | 697 | 'type-with-number' => [ |
698 | 698 | 'constraints' => [ |
699 | - 'mandatory' => [ 'a-magic-number' ], |
|
700 | - 'rules' => [ 'a-magic-number' => [ 'scalar' => 'integer' ] ], |
|
699 | + 'mandatory' => ['a-magic-number'], |
|
700 | + 'rules' => ['a-magic-number' => ['scalar' => 'integer']], |
|
701 | 701 | ] |
702 | 702 | ], |
703 | 703 | ], |
@@ -723,7 +723,7 @@ discard block |
||
723 | 723 | 'first-email', |
724 | 724 | ], |
725 | 725 | 'rules' => [ |
726 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
726 | + 'first-email' => ['custom-validator' => 'email'], |
|
727 | 727 | ], |
728 | 728 | ] |
729 | 729 | ], |
@@ -756,7 +756,7 @@ discard block |
||
756 | 756 | 'first-email', |
757 | 757 | ], |
758 | 758 | 'rules' => [ |
759 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
759 | + 'first-email' => ['custom-validator' => 'email'], |
|
760 | 760 | ], |
761 | 761 | ] |
762 | 762 | ], |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | |
787 | 787 | public function testProvideRule() |
788 | 788 | { |
789 | - $aSpecificRule = [ 'custom-validator' => 'email' ]; |
|
789 | + $aSpecificRule = ['custom-validator' => 'email']; |
|
790 | 790 | |
791 | 791 | $configurator = new Configurator( |
792 | 792 | 'email-resource', |
@@ -12,7 +12,6 @@ |
||
12 | 12 | namespace Sensorario\Resources; |
13 | 13 | |
14 | 14 | use Sensorario\Resources\Configurator; |
15 | -use Sensorario\Resources\Exceptions\EmptyComnfigurationException; |
|
16 | 15 | use Sensorario\Resources\Validators\ResourcesValidator; |
17 | 16 | |
18 | 17 | /** |
@@ -65,7 +65,7 @@ |
||
65 | 65 | foreach ($properties as $k => $v) { |
66 | 66 | if ('object' === gettype($v) && !isset($this->rules()[$k])) { |
67 | 67 | throw new \Sensorario\Resources\Exceptions\PropertyWithoutRuleException( |
68 | - 'When property `' . $k . '` is an object class, must be defined in Resources::rules()'. |
|
68 | + 'When property `' . $k . '` is an object class, must be defined in Resources::rules()' . |
|
69 | 69 | ' but rules here are equals to ' . var_export($this->rules(), true) |
70 | 70 | . ' And properties are ' . var_export($this->properties, true) |
71 | 71 | ); |
@@ -36,7 +36,7 @@ |
||
36 | 36 | if (!$isAllowed) { |
37 | 37 | throw new \Sensorario\Resources\Exceptions\NotAllowedKeyException( |
38 | 38 | "Key `" . get_class($resource) |
39 | - . "::\$$key` with value `" . $value |
|
39 | + . "::\$$key` with value `" . $value |
|
40 | 40 | . "` is not allowed" |
41 | 41 | ); |
42 | 42 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | if ($this->typeMismatch()) { |
74 | 74 | if ($this->resource->isFieldNumericButString($this->fieldName)) { |
75 | 75 | throw new \Sensorario\Resources\Exceptions\WrongPropertyValueException( |
76 | - 'Property `'.$this->fieldName.'` must be an integer!' |
|
76 | + 'Property `' . $this->fieldName . '` must be an integer!' |
|
77 | 77 | ); |
78 | 78 | } |
79 | 79 | |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | |
106 | 106 | if ($this->rule->isNotMail()) { |
107 | 107 | throw new \Sensorario\Resources\Exceptions\InvalidCustomValidatorException( |
108 | - 'Oops! `'. $this->rule->getRuleType() .'` custom validator is not available. Only email is.' |
|
108 | + 'Oops! `' . $this->rule->getRuleType() . '` custom validator is not available. Only email is.' |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | } |