@@ -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() |
@@ -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( |
@@ -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 | } |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | |
293 | 293 | public function testPropertiesAccessor() |
294 | 294 | { |
295 | - $aSpecificRule = [ 'custom-validator' => 'email' ]; |
|
295 | + $aSpecificRule = ['custom-validator' => 'email']; |
|
296 | 296 | |
297 | 297 | $configurator = new Configurator( |
298 | 298 | 'email-resource', |
@@ -406,7 +406,7 @@ discard block |
||
406 | 406 | 'resources' => [ |
407 | 407 | 'bar' => [ |
408 | 408 | 'constraints' => [ |
409 | - 'allowed' => [ 'allowed_property_name' ], |
|
409 | + 'allowed' => ['allowed_property_name'], |
|
410 | 410 | ] |
411 | 411 | ], |
412 | 412 | ], |
@@ -415,7 +415,7 @@ discard block |
||
415 | 415 | ); |
416 | 416 | |
417 | 417 | $this->assertEquals( |
418 | - [ 'allowed_property_name' ], |
|
418 | + ['allowed_property_name'], |
|
419 | 419 | $resource->allowed('bar') |
420 | 420 | ); |
421 | 421 | } |
@@ -457,19 +457,19 @@ discard block |
||
457 | 457 | 'resources' => [ |
458 | 458 | 'foo' => [ |
459 | 459 | 'constraints' => [ |
460 | - 'allowed' => [ 'allowed_property_name' ], |
|
460 | + 'allowed' => ['allowed_property_name'], |
|
461 | 461 | ] |
462 | 462 | ], |
463 | 463 | 'unused_resource' => [ |
464 | 464 | 'constraints' => [ |
465 | - 'allowed' => [ 'bar' ], |
|
465 | + 'allowed' => ['bar'], |
|
466 | 466 | ] |
467 | 467 | ], |
468 | 468 | ], |
469 | 469 | ]); |
470 | 470 | |
471 | 471 | $this->assertEquals( |
472 | - [ 'allowed_property_name' ], |
|
472 | + ['allowed_property_name'], |
|
473 | 473 | $container->allowed('foo') |
474 | 474 | ); |
475 | 475 | } |
@@ -521,14 +521,14 @@ discard block |
||
521 | 521 | 'resources' => [ |
522 | 522 | 'foo' => [ |
523 | 523 | 'constraints' => [ |
524 | - 'mandatory' => [ 'mandatory_property' ], |
|
524 | + 'mandatory' => ['mandatory_property'], |
|
525 | 525 | ] |
526 | 526 | ], |
527 | 527 | ], |
528 | 528 | ]); |
529 | 529 | |
530 | 530 | $this->assertEquals( |
531 | - [ 'mandatory_property' ], |
|
531 | + ['mandatory_property'], |
|
532 | 532 | $container->allowed('foo') |
533 | 533 | ); |
534 | 534 | } |
@@ -541,8 +541,8 @@ discard block |
||
541 | 541 | 'resources' => [ |
542 | 542 | 'foo' => [ |
543 | 543 | 'constraints' => [ |
544 | - 'mandatory' => [ 'date' ], |
|
545 | - 'rules' => [ 'date' => [ 'object' => 'DateTime' ] ], |
|
544 | + 'mandatory' => ['date'], |
|
545 | + 'rules' => ['date' => ['object' => 'DateTime']], |
|
546 | 546 | ] |
547 | 547 | ], |
548 | 548 | ], |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | 'resources' => [ |
569 | 569 | 'foo' => [ |
570 | 570 | 'constraints' => [ |
571 | - 'allowed' => [ 'user_type' ], |
|
571 | + 'allowed' => ['user_type'], |
|
572 | 572 | 'allowedValues' => [ |
573 | 573 | 'user_type' => [ |
574 | 574 | 4, |
@@ -581,7 +581,7 @@ discard block |
||
581 | 581 | ]) |
582 | 582 | ); |
583 | 583 | |
584 | - $properties = [ 'user_type' => 3 ]; |
|
584 | + $properties = ['user_type' => 3]; |
|
585 | 585 | |
586 | 586 | Resource::box( |
587 | 587 | $properties, |
@@ -670,7 +670,7 @@ discard block |
||
670 | 670 | ); |
671 | 671 | |
672 | 672 | Resource::box( |
673 | - [ 'age' => 2 ], |
|
673 | + ['age' => 2], |
|
674 | 674 | $configurator |
675 | 675 | ); |
676 | 676 | } |
@@ -770,7 +770,7 @@ discard block |
||
770 | 770 | 'first-email', |
771 | 771 | ], |
772 | 772 | 'rules' => [ |
773 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
773 | + 'first-email' => ['custom-validator' => 'email'], |
|
774 | 774 | ], |
775 | 775 | ] |
776 | 776 | ], |
@@ -797,8 +797,8 @@ discard block |
||
797 | 797 | 'resources' => [ |
798 | 798 | 'type-with-number' => [ |
799 | 799 | 'constraints' => [ |
800 | - 'mandatory' => [ 'a-magic-number' ], |
|
801 | - 'rules' => [ 'a-magic-number' => [ 'scalar' => 'integer' ] ], |
|
800 | + 'mandatory' => ['a-magic-number'], |
|
801 | + 'rules' => ['a-magic-number' => ['scalar' => 'integer']], |
|
802 | 802 | ] |
803 | 803 | ], |
804 | 804 | ], |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | 'first-email', |
825 | 825 | ], |
826 | 826 | 'rules' => [ |
827 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
827 | + 'first-email' => ['custom-validator' => 'email'], |
|
828 | 828 | ], |
829 | 829 | ] |
830 | 830 | ], |
@@ -857,7 +857,7 @@ discard block |
||
857 | 857 | 'first-email', |
858 | 858 | ], |
859 | 859 | 'rules' => [ |
860 | - 'first-email' => [ 'custom-validator' => 'email' ], |
|
860 | + 'first-email' => ['custom-validator' => 'email'], |
|
861 | 861 | ], |
862 | 862 | ] |
863 | 863 | ], |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | |
888 | 888 | public function testProvideRule() |
889 | 889 | { |
890 | - $aSpecificRule = [ 'custom-validator' => 'email' ]; |
|
890 | + $aSpecificRule = ['custom-validator' => 'email']; |
|
891 | 891 | |
892 | 892 | $configurator = new Configurator( |
893 | 893 | 'email-resource', |
@@ -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 TestCase |