@@ -94,7 +94,7 @@ |
||
94 | 94 | { |
95 | 95 | $checker = new TypeChecker(); |
96 | 96 | |
97 | - foreach (\DateTimeZone::listIdentifiers() as $identifier) { |
|
97 | + foreach (\DateTimeZone::listIdentifiers() as $identifier){ |
|
98 | 98 | $this->assertTrue($checker->timezone($identifier)); |
99 | 99 | $this->assertFalse($checker->timezone(str_rot13($identifier))); |
100 | 100 | } |
@@ -94,7 +94,8 @@ |
||
94 | 94 | { |
95 | 95 | $checker = new TypeChecker(); |
96 | 96 | |
97 | - foreach (\DateTimeZone::listIdentifiers() as $identifier) { |
|
97 | + foreach (\DateTimeZone::listIdentifiers() as $identifier) |
|
98 | + { |
|
98 | 99 | $this->assertTrue($checker->timezone($identifier)); |
99 | 100 | $this->assertFalse($checker->timezone(str_rot13($identifier))); |
100 | 101 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | |
30 | 30 | public function testValid(): void |
31 | 31 | { |
32 | - $file = __DIR__ . '/fixtures/sample-1.jpg'; |
|
32 | + $file = __DIR__.'/fixtures/sample-1.jpg'; |
|
33 | 33 | |
34 | 34 | $this->assertValid([ |
35 | 35 | 'i' => $file |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | 'i' => ['image:valid'] |
62 | 62 | ]); |
63 | 63 | |
64 | - $file = __DIR__ . '/fixtures/sample-2.png'; |
|
64 | + $file = __DIR__.'/fixtures/sample-2.png'; |
|
65 | 65 | |
66 | 66 | $this->assertValid([ |
67 | 67 | 'i' => $file |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | 'i' => ['image:valid'] |
70 | 70 | ]); |
71 | 71 | |
72 | - $file = __DIR__ . '/fixtures/sample-3.gif'; |
|
72 | + $file = __DIR__.'/fixtures/sample-3.gif'; |
|
73 | 73 | |
74 | 74 | $this->assertValid([ |
75 | 75 | 'i' => $file |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | 'i' => ['image:valid'] |
78 | 78 | ]); |
79 | 79 | |
80 | - $file = __DIR__ . '/fixtures/hack.jpg'; |
|
80 | + $file = __DIR__.'/fixtures/hack.jpg'; |
|
81 | 81 | |
82 | 82 | $this->assertNotValid('i', [ |
83 | 83 | 'i' => $file |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | |
95 | 95 | public function testSmaller(): void |
96 | 96 | { |
97 | - $file = __DIR__ . '/fixtures/sample-1.jpg'; |
|
97 | + $file = __DIR__.'/fixtures/sample-1.jpg'; |
|
98 | 98 | |
99 | 99 | $this->assertValid([ |
100 | 100 | 'i' => $file |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | |
115 | 115 | |
116 | 116 | $this->assertNotValid('i', [ |
117 | - 'i' => __DIR__ . '/fixtures/hack.jpg' |
|
117 | + 'i' => __DIR__.'/fixtures/hack.jpg' |
|
118 | 118 | ], [ |
119 | 119 | 'i' => [ |
120 | 120 | ['image:smaller', 150, 150] |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | |
125 | 125 | public function testBigger(): void |
126 | 126 | { |
127 | - $file = __DIR__ . '/fixtures/sample-1.jpg'; |
|
127 | + $file = __DIR__.'/fixtures/sample-1.jpg'; |
|
128 | 128 | |
129 | 129 | $this->assertValid([ |
130 | 130 | 'i' => $file |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | ]); |
144 | 144 | |
145 | 145 | $this->assertNotValid('i', [ |
146 | - 'i' => __DIR__ . '/fixtures/hack.jpg' |
|
146 | + 'i' => __DIR__.'/fixtures/hack.jpg' |
|
147 | 147 | ], [ |
148 | 148 | 'i' => [ |
149 | 149 | ['image:bigger', 150, 150] |
@@ -21,7 +21,7 @@ |
||
21 | 21 | 'name' => 'string' |
22 | 22 | ], [ |
23 | 23 | 'name' => [ |
24 | - static function () { |
|
24 | + static function (){ |
|
25 | 25 | return false; |
26 | 26 | } |
27 | 27 | ] |
@@ -21,7 +21,8 @@ |
||
21 | 21 | 'name' => 'string' |
22 | 22 | ], [ |
23 | 23 | 'name' => [ |
24 | - static function () { |
|
24 | + static function () |
|
25 | + { |
|
25 | 26 | return false; |
26 | 27 | } |
27 | 28 | ] |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | public function isMet(ValidatorInterface $validator, string $field, $value): bool |
20 | 20 | { |
21 | 21 | $payload = $this->getPayload($validator)['j']; |
22 | - switch ($field) { |
|
22 | + switch ($field){ |
|
23 | 23 | case 'i': |
24 | 24 | return $value === $payload - 1; |
25 | 25 | |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | protected function getPayload(ValidatorInterface $validator): array |
43 | 43 | { |
44 | 44 | $payload = []; |
45 | - foreach ($this->options as $option) { |
|
45 | + foreach ($this->options as $option){ |
|
46 | 46 | $payload[$option] = $validator->getValue( |
47 | 47 | $option, |
48 | 48 | $validator->getContext()[$option] ?? null |
@@ -19,7 +19,8 @@ discard block |
||
19 | 19 | public function isMet(ValidatorInterface $validator, string $field, $value): bool |
20 | 20 | { |
21 | 21 | $payload = $this->getPayload($validator)['j']; |
22 | - switch ($field) { |
|
22 | + switch ($field) |
|
23 | + { |
|
23 | 24 | case 'i': |
24 | 25 | return $value === $payload - 1; |
25 | 26 | |
@@ -42,7 +43,8 @@ discard block |
||
42 | 43 | protected function getPayload(ValidatorInterface $validator): array |
43 | 44 | { |
44 | 45 | $payload = []; |
45 | - foreach ($this->options as $option) { |
|
46 | + foreach ($this->options as $option) |
|
47 | + { |
|
46 | 48 | $payload[$option] = $validator->getValue( |
47 | 49 | $option, |
48 | 50 | $validator->getContext()[$option] ?? null |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | ] |
86 | 86 | ]); |
87 | 87 | |
88 | - foreach ($rules as $rule) { |
|
88 | + foreach ($rules as $rule){ |
|
89 | 89 | $count = 0; |
90 | - foreach ($rule->getConditions() as $condition) { |
|
90 | + foreach ($rule->getConditions() as $condition){ |
|
91 | 91 | $this->assertInstanceOf(TestCondition::class, $condition); |
92 | 92 | $count++; |
93 | 93 | } |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | ]); |
108 | 108 | |
109 | 109 | $validator = $this->validation->validate(['i' => 1, 'j' => 2], [], ['k' => 3]); |
110 | - foreach ($rules as $rule) { |
|
111 | - foreach ($rule->getConditions() as $condition) { |
|
110 | + foreach ($rules as $rule){ |
|
111 | + foreach ($rule->getConditions() as $condition){ |
|
112 | 112 | $this->assertTrue($condition->isMet($validator, 'i', 1)); |
113 | 113 | $this->assertTrue($condition->isMet($validator, 'j', 2)); |
114 | 114 | $this->assertTrue($condition->isMet($validator, 'k', 3)); |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | public function testAbsent(): void |
122 | 122 | { |
123 | 123 | $this->assertValid( |
124 | - ['i' => 'a',], |
|
124 | + ['i' => 'a', ], |
|
125 | 125 | ['i' => [['notEmpty', 'if' => ['absent' => ['b', 'c']]]]] |
126 | 126 | ); |
127 | 127 | |
@@ -140,18 +140,18 @@ discard block |
||
140 | 140 | public function testPresent(): void |
141 | 141 | { |
142 | 142 | $this->assertValid( |
143 | - ['i' => '',], |
|
143 | + ['i' => '', ], |
|
144 | 144 | ['i' => [['notEmpty', 'if' => ['present' => ['b', 'c']]]]] |
145 | 145 | ); |
146 | 146 | |
147 | 147 | $this->assertValid( |
148 | - ['b' => 'b',], |
|
148 | + ['b' => 'b', ], |
|
149 | 149 | ['i' => [['notEmpty', 'if' => ['present' => ['i']]]]] |
150 | 150 | ); |
151 | 151 | |
152 | 152 | $this->assertNotValid( |
153 | 153 | 'i', |
154 | - ['i' => '',], |
|
154 | + ['i' => '', ], |
|
155 | 155 | ['i' => [['notEmpty', 'if' => ['present' => ['i']]]]] |
156 | 156 | ); |
157 | 157 | |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | public function testWithAny(): void |
166 | 166 | { |
167 | 167 | $this->assertValid( |
168 | - ['i' => 'a',], |
|
168 | + ['i' => 'a', ], |
|
169 | 169 | ['i' => [['is_bool', 'if' => ['withAny' => ['b', 'c']]]]] |
170 | 170 | ); |
171 | 171 | |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | public function testWithAll(): void |
186 | 186 | { |
187 | 187 | $this->assertValid( |
188 | - ['i' => 'a',], |
|
188 | + ['i' => 'a', ], |
|
189 | 189 | ['i' => [['is_bool', 'if' => ['withAll' => ['b', 'c']]]]] |
190 | 190 | ); |
191 | 191 | |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | { |
206 | 206 | $this->assertNotValid( |
207 | 207 | 'i', |
208 | - ['i' => 'a',], |
|
208 | + ['i' => 'a', ], |
|
209 | 209 | ['i' => [['is_bool', 'if' => ['withoutAny' => ['b', 'c']]]]] |
210 | 210 | ); |
211 | 211 | |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | { |
226 | 226 | $this->assertNotValid( |
227 | 227 | 'i', |
228 | - ['i' => 'a',], |
|
228 | + ['i' => 'a', ], |
|
229 | 229 | ['i' => [['is_bool', 'if' => ['withoutAll' => ['b', 'c']]]]] |
230 | 230 | ); |
231 | 231 |
@@ -85,9 +85,11 @@ discard block |
||
85 | 85 | ] |
86 | 86 | ]); |
87 | 87 | |
88 | - foreach ($rules as $rule) { |
|
88 | + foreach ($rules as $rule) |
|
89 | + { |
|
89 | 90 | $count = 0; |
90 | - foreach ($rule->getConditions() as $condition) { |
|
91 | + foreach ($rule->getConditions() as $condition) |
|
92 | + { |
|
91 | 93 | $this->assertInstanceOf(TestCondition::class, $condition); |
92 | 94 | $count++; |
93 | 95 | } |
@@ -107,8 +109,10 @@ discard block |
||
107 | 109 | ]); |
108 | 110 | |
109 | 111 | $validator = $this->validation->validate(['i' => 1, 'j' => 2], [], ['k' => 3]); |
110 | - foreach ($rules as $rule) { |
|
111 | - foreach ($rule->getConditions() as $condition) { |
|
112 | + foreach ($rules as $rule) |
|
113 | + { |
|
114 | + foreach ($rule->getConditions() as $condition) |
|
115 | + { |
|
112 | 116 | $this->assertTrue($condition->isMet($validator, 'i', 1)); |
113 | 117 | $this->assertTrue($condition->isMet($validator, 'j', 2)); |
114 | 118 | $this->assertTrue($condition->isMet($validator, 'k', 3)); |
@@ -142,7 +142,7 @@ |
||
142 | 142 | $v = $this->validation->validate([ |
143 | 143 | 'i' => 'third' |
144 | 144 | ], [ |
145 | - 'i' => static function () { |
|
145 | + 'i' => static function (){ |
|
146 | 146 | return false; |
147 | 147 | } |
148 | 148 | ]); |
@@ -142,7 +142,8 @@ |
||
142 | 142 | $v = $this->validation->validate([ |
143 | 143 | 'i' => 'third' |
144 | 144 | ], [ |
145 | - 'i' => static function () { |
|
145 | + 'i' => static function () |
|
146 | + { |
|
146 | 147 | return false; |
147 | 148 | } |
148 | 149 | ]); |
@@ -37,8 +37,8 @@ discard block |
||
37 | 37 | { |
38 | 38 | //De-mapping |
39 | 39 | $mapped = []; |
40 | - foreach ($errors as $field => $message) { |
|
41 | - if (!isset($this->schema[$field])) { |
|
40 | + foreach ($errors as $field => $message){ |
|
41 | + if (!isset($this->schema[$field])){ |
|
42 | 42 | $mapped[$field] = $message; |
43 | 43 | continue; |
44 | 44 | } |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | */ |
61 | 61 | private function mount(array &$array, string $path, $message): void |
62 | 62 | { |
63 | - if ($path === '.') { |
|
63 | + if ($path === '.'){ |
|
64 | 64 | throw new SchemaException( |
65 | 65 | "Unable to mount error `{$message}` to `{$path}` (root path is forbidden)" |
66 | 66 | ); |
67 | 67 | } |
68 | 68 | |
69 | 69 | $step = explode('.', $path); |
70 | - while ($name = array_shift($step)) { |
|
70 | + while ($name = array_shift($step)){ |
|
71 | 71 | $array = &$array[$name]; |
72 | 72 | } |
73 | 73 |
@@ -37,8 +37,10 @@ discard block |
||
37 | 37 | { |
38 | 38 | //De-mapping |
39 | 39 | $mapped = []; |
40 | - foreach ($errors as $field => $message) { |
|
41 | - if (!isset($this->schema[$field])) { |
|
40 | + foreach ($errors as $field => $message) |
|
41 | + { |
|
42 | + if (!isset($this->schema[$field])) |
|
43 | + { |
|
42 | 44 | $mapped[$field] = $message; |
43 | 45 | continue; |
44 | 46 | } |
@@ -60,14 +62,16 @@ discard block |
||
60 | 62 | */ |
61 | 63 | private function mount(array &$array, string $path, $message): void |
62 | 64 | { |
63 | - if ($path === '.') { |
|
65 | + if ($path === '.') |
|
66 | + { |
|
64 | 67 | throw new SchemaException( |
65 | 68 | "Unable to mount error `{$message}` to `{$path}` (root path is forbidden)" |
66 | 69 | ); |
67 | 70 | } |
68 | 71 | |
69 | 72 | $step = explode('.', $path); |
70 | - while ($name = array_shift($step)) { |
|
73 | + while ($name = array_shift($step)) |
|
74 | + { |
|
71 | 75 | $array = &$array[$name]; |
72 | 76 | } |
73 | 77 |
@@ -38,10 +38,10 @@ discard block |
||
38 | 38 | public function withPrefix(string $prefix, bool $add = true): InputInterface |
39 | 39 | { |
40 | 40 | $input = clone $this; |
41 | - if ($add) { |
|
42 | - $input->prefix .= '.' . $prefix; |
|
41 | + if ($add){ |
|
42 | + $input->prefix .= '.'.$prefix; |
|
43 | 43 | $input->prefix = trim($input->prefix, '.'); |
44 | - } else { |
|
44 | + }else{ |
|
45 | 45 | $input->prefix = $prefix; |
46 | 46 | } |
47 | 47 | return $input; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | */ |
53 | 53 | public function getValue(string $source, string $name = null) |
54 | 54 | { |
55 | - try { |
|
55 | + try{ |
|
56 | 56 | return $this->dotGet($name); |
57 | - } catch (DotNotFoundException $e) { |
|
57 | + }catch (DotNotFoundException $e){ |
|
58 | 58 | return null; |
59 | 59 | } |
60 | 60 | } |
@@ -72,14 +72,14 @@ discard block |
||
72 | 72 | $data = $this->data; |
73 | 73 | |
74 | 74 | //Generating path relative to a given name and prefix |
75 | - $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
|
76 | - if (empty($path)) { |
|
75 | + $path = (!empty($this->prefix) ? $this->prefix.'.' : '').$name; |
|
76 | + if (empty($path)){ |
|
77 | 77 | return $data; |
78 | 78 | } |
79 | 79 | |
80 | 80 | $path = explode('.', rtrim($path, '.')); |
81 | - foreach ($path as $step) { |
|
82 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
81 | + foreach ($path as $step){ |
|
82 | + if (!is_array($data) || !array_key_exists($step, $data)){ |
|
83 | 83 | throw new DotNotFoundException("Unable to find requested element '{$name}'"); |
84 | 84 | } |
85 | 85 | $data = &$data[$step]; |
@@ -38,10 +38,13 @@ discard block |
||
38 | 38 | public function withPrefix(string $prefix, bool $add = true): InputInterface |
39 | 39 | { |
40 | 40 | $input = clone $this; |
41 | - if ($add) { |
|
41 | + if ($add) |
|
42 | + { |
|
42 | 43 | $input->prefix .= '.' . $prefix; |
43 | 44 | $input->prefix = trim($input->prefix, '.'); |
44 | - } else { |
|
45 | + } |
|
46 | + else |
|
47 | + { |
|
45 | 48 | $input->prefix = $prefix; |
46 | 49 | } |
47 | 50 | return $input; |
@@ -52,9 +55,12 @@ discard block |
||
52 | 55 | */ |
53 | 56 | public function getValue(string $source, string $name = null) |
54 | 57 | { |
55 | - try { |
|
58 | + try |
|
59 | + { |
|
56 | 60 | return $this->dotGet($name); |
57 | - } catch (DotNotFoundException $e) { |
|
61 | + } |
|
62 | + catch (DotNotFoundException $e) |
|
63 | + { |
|
58 | 64 | return null; |
59 | 65 | } |
60 | 66 | } |
@@ -73,13 +79,16 @@ discard block |
||
73 | 79 | |
74 | 80 | //Generating path relative to a given name and prefix |
75 | 81 | $path = (!empty($this->prefix) ? $this->prefix . '.' : '') . $name; |
76 | - if (empty($path)) { |
|
82 | + if (empty($path)) |
|
83 | + { |
|
77 | 84 | return $data; |
78 | 85 | } |
79 | 86 | |
80 | 87 | $path = explode('.', rtrim($path, '.')); |
81 | - foreach ($path as $step) { |
|
82 | - if (!is_array($data) || !array_key_exists($step, $data)) { |
|
88 | + foreach ($path as $step) |
|
89 | + { |
|
90 | + if (!is_array($data) || !array_key_exists($step, $data)) |
|
91 | + { |
|
83 | 92 | throw new DotNotFoundException("Unable to find requested element '{$name}'"); |
84 | 93 | } |
85 | 94 | $data = &$data[$step]; |
@@ -18,6 +18,6 @@ |
||
18 | 18 | { |
19 | 19 | public function process(string $controller, string $action, array $parameters, CoreInterface $core) |
20 | 20 | { |
21 | - return '?' . $core->callAction($controller, $action, $parameters) . '!'; |
|
21 | + return '?'.$core->callAction($controller, $action, $parameters).'!'; |
|
22 | 22 | } |
23 | 23 | } |