@@ -33,7 +33,7 @@ |
||
33 | 33 | 'connections' => [ |
34 | 34 | 'runtime' => [ |
35 | 35 | 'driver' => SQLiteDriver::class, |
36 | - 'connection' => 'sqlite:' . directory('runtime') . 'runtime.db', |
|
36 | + 'connection' => 'sqlite:'.directory('runtime').'runtime.db', |
|
37 | 37 | 'profiling' => env('DEBUG', false), |
38 | 38 | 'username' => 'sqlite', |
39 | 39 | 'password' => '', |
@@ -26,9 +26,9 @@ discard block |
||
26 | 26 | public function testFromEntity(): void |
27 | 27 | { |
28 | 28 | $line = __LINE__; |
29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
29 | + $className = __NAMESPACE__."\\App\\Request\\Sample{$line}Request"; |
|
30 | 30 | $output = $this->console()->run('create:filter', [ |
31 | - 'name' => 'sample' . $line, |
|
31 | + 'name' => 'sample'.$line, |
|
32 | 32 | '--entity' => SourceEntity74::class |
33 | 33 | ]); |
34 | 34 | |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | |
40 | 40 | $reflection = new ReflectionClass($className); |
41 | 41 | |
42 | - try { |
|
42 | + try{ |
|
43 | 43 | $schema = $reflection->getConstant('SCHEMA'); |
44 | 44 | $this->assertSame('data:typedBool', $schema['typedBool']); |
45 | 45 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
54 | 54 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
55 | 55 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
56 | - } finally { |
|
56 | + }finally{ |
|
57 | 57 | $this->deleteDeclaration($className); |
58 | 58 | } |
59 | 59 | } |
@@ -39,7 +39,8 @@ discard block |
||
39 | 39 | |
40 | 40 | $reflection = new ReflectionClass($className); |
41 | 41 | |
42 | - try { |
|
42 | + try |
|
43 | + { |
|
43 | 44 | $schema = $reflection->getConstant('SCHEMA'); |
44 | 45 | $this->assertSame('data:typedBool', $schema['typedBool']); |
45 | 46 | $this->assertSame('data:noTypeString', $schema['noTypeString']); |
@@ -53,7 +54,9 @@ discard block |
||
53 | 54 | $this->assertSame(['notEmpty', 'string'], $validates['obj']); |
54 | 55 | $this->assertSame(['notEmpty', 'integer'], $validates['intFromPhpDoc']); |
55 | 56 | $this->assertSame(['notEmpty', 'float'], $validates['noTypeWithFloatDefault']); |
56 | - } finally { |
|
57 | + } |
|
58 | + finally |
|
59 | + { |
|
57 | 60 | $this->deleteDeclaration($className); |
58 | 61 | } |
59 | 62 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | public function testFromEntity(): void |
27 | 27 | { |
28 | 28 | $line = __LINE__; |
29 | - $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}Request"; |
|
29 | + $className = __NAMESPACE__ . "\\App\\Request\\Sample{$line}request"; |
|
30 | 30 | $output = $this->console()->run('create:filter', [ |
31 | 31 | 'name' => 'sample' . $line, |
32 | 32 | '--entity' => SourceEntity74::class |
@@ -63,9 +63,9 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function findClasses(string $annotation): iterable |
65 | 65 | { |
66 | - foreach ($this->getTargets() as $target) { |
|
66 | + foreach ($this->getTargets() as $target){ |
|
67 | 67 | $found = $this->reader->getClassAnnotation($target, $annotation); |
68 | - if ($found !== null) { |
|
68 | + if ($found !== null){ |
|
69 | 69 | yield new AnnotatedClass($target, $found); |
70 | 70 | } |
71 | 71 | } |
@@ -79,10 +79,10 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function findMethods(string $annotation): iterable |
81 | 81 | { |
82 | - foreach ($this->getTargets() as $target) { |
|
83 | - foreach ($target->getMethods() as $method) { |
|
82 | + foreach ($this->getTargets() as $target){ |
|
83 | + foreach ($target->getMethods() as $method){ |
|
84 | 84 | $found = $this->reader->getMethodAnnotation($method, $annotation); |
85 | - if ($found !== null) { |
|
85 | + if ($found !== null){ |
|
86 | 86 | yield new AnnotatedMethod($method, $found); |
87 | 87 | } |
88 | 88 | } |
@@ -97,10 +97,10 @@ discard block |
||
97 | 97 | */ |
98 | 98 | public function findProperties(string $annotation): iterable |
99 | 99 | { |
100 | - foreach ($this->getTargets() as $target) { |
|
101 | - foreach ($target->getProperties() as $property) { |
|
100 | + foreach ($this->getTargets() as $target){ |
|
101 | + foreach ($target->getProperties() as $property){ |
|
102 | 102 | $found = $this->reader->getPropertyAnnotation($property, $annotation); |
103 | - if ($found !== null) { |
|
103 | + if ($found !== null){ |
|
104 | 104 | yield new AnnotatedProperty($property, $found); |
105 | 105 | } |
106 | 106 | } |
@@ -112,12 +112,12 @@ discard block |
||
112 | 112 | */ |
113 | 113 | private function getTargets(): iterable |
114 | 114 | { |
115 | - if ($this->targets === []) { |
|
115 | + if ($this->targets === []){ |
|
116 | 116 | yield from $this->classLocator->getClasses(); |
117 | 117 | return; |
118 | 118 | } |
119 | 119 | |
120 | - foreach ($this->targets as $target) { |
|
120 | + foreach ($this->targets as $target){ |
|
121 | 121 | yield from $this->classLocator->getClasses($target); |
122 | 122 | } |
123 | 123 | } |
@@ -63,9 +63,11 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function findClasses(string $annotation): iterable |
65 | 65 | { |
66 | - foreach ($this->getTargets() as $target) { |
|
66 | + foreach ($this->getTargets() as $target) |
|
67 | + { |
|
67 | 68 | $found = $this->reader->getClassAnnotation($target, $annotation); |
68 | - if ($found !== null) { |
|
69 | + if ($found !== null) |
|
70 | + { |
|
69 | 71 | yield new AnnotatedClass($target, $found); |
70 | 72 | } |
71 | 73 | } |
@@ -79,10 +81,13 @@ discard block |
||
79 | 81 | */ |
80 | 82 | public function findMethods(string $annotation): iterable |
81 | 83 | { |
82 | - foreach ($this->getTargets() as $target) { |
|
83 | - foreach ($target->getMethods() as $method) { |
|
84 | + foreach ($this->getTargets() as $target) |
|
85 | + { |
|
86 | + foreach ($target->getMethods() as $method) |
|
87 | + { |
|
84 | 88 | $found = $this->reader->getMethodAnnotation($method, $annotation); |
85 | - if ($found !== null) { |
|
89 | + if ($found !== null) |
|
90 | + { |
|
86 | 91 | yield new AnnotatedMethod($method, $found); |
87 | 92 | } |
88 | 93 | } |
@@ -97,10 +102,13 @@ discard block |
||
97 | 102 | */ |
98 | 103 | public function findProperties(string $annotation): iterable |
99 | 104 | { |
100 | - foreach ($this->getTargets() as $target) { |
|
101 | - foreach ($target->getProperties() as $property) { |
|
105 | + foreach ($this->getTargets() as $target) |
|
106 | + { |
|
107 | + foreach ($target->getProperties() as $property) |
|
108 | + { |
|
102 | 109 | $found = $this->reader->getPropertyAnnotation($property, $annotation); |
103 | - if ($found !== null) { |
|
110 | + if ($found !== null) |
|
111 | + { |
|
104 | 112 | yield new AnnotatedProperty($property, $found); |
105 | 113 | } |
106 | 114 | } |
@@ -112,12 +120,14 @@ discard block |
||
112 | 120 | */ |
113 | 121 | private function getTargets(): iterable |
114 | 122 | { |
115 | - if ($this->targets === []) { |
|
123 | + if ($this->targets === []) |
|
124 | + { |
|
116 | 125 | yield from $this->classLocator->getClasses(); |
117 | 126 | return; |
118 | 127 | } |
119 | 128 | |
120 | - foreach ($this->targets as $target) { |
|
129 | + foreach ($this->targets as $target) |
|
130 | + { |
|
121 | 131 | yield from $this->classLocator->getClasses($target); |
122 | 132 | } |
123 | 133 | } |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | { |
24 | 24 | public function testLocateClasses() |
25 | 25 | { |
26 | - $classes = $this->getLocator(__DIR__ . '/Fixtures')->findClasses(Value::class); |
|
26 | + $classes = $this->getLocator(__DIR__.'/Fixtures')->findClasses(Value::class); |
|
27 | 27 | $classes = iterator_to_array($classes); |
28 | 28 | |
29 | 29 | $this->assertCount(1, $classes); |
30 | 30 | |
31 | - foreach ($classes as $class) { |
|
31 | + foreach ($classes as $class){ |
|
32 | 32 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
33 | 33 | $this->assertSame('abc', $class->getAnnotation()->value); |
34 | 34 | } |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | |
37 | 37 | public function testLocateProperties() |
38 | 38 | { |
39 | - $props = $this->getLocator(__DIR__ . '/Fixtures')->findProperties(Another::class); |
|
39 | + $props = $this->getLocator(__DIR__.'/Fixtures')->findProperties(Another::class); |
|
40 | 40 | $props = iterator_to_array($props); |
41 | 41 | |
42 | 42 | $this->assertCount(1, $props); |
43 | 43 | |
44 | - foreach ($props as $prop) { |
|
44 | + foreach ($props as $prop){ |
|
45 | 45 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
46 | 46 | $this->assertSame('name', $prop->getProperty()->getName()); |
47 | 47 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | |
51 | 51 | public function testLocateMethods() |
52 | 52 | { |
53 | - $methods = $this->getLocator(__DIR__ . '/Fixtures')->findMethods(Route::class); |
|
53 | + $methods = $this->getLocator(__DIR__.'/Fixtures')->findMethods(Route::class); |
|
54 | 54 | $methods = iterator_to_array($methods); |
55 | 55 | |
56 | 56 | $this->assertCount(1, $methods); |
57 | 57 | |
58 | - foreach ($methods as $m) { |
|
58 | + foreach ($methods as $m){ |
|
59 | 59 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
60 | 60 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
61 | 61 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -28,7 +28,8 @@ discard block |
||
28 | 28 | |
29 | 29 | $this->assertCount(1, $classes); |
30 | 30 | |
31 | - foreach ($classes as $class) { |
|
31 | + foreach ($classes as $class) |
|
32 | + { |
|
32 | 33 | $this->assertSame(TestClass::class, $class->getClass()->getName()); |
33 | 34 | $this->assertSame('abc', $class->getAnnotation()->value); |
34 | 35 | } |
@@ -41,7 +42,8 @@ discard block |
||
41 | 42 | |
42 | 43 | $this->assertCount(1, $props); |
43 | 44 | |
44 | - foreach ($props as $prop) { |
|
45 | + foreach ($props as $prop) |
|
46 | + { |
|
45 | 47 | $this->assertSame(TestClass::class, $prop->getClass()->getName()); |
46 | 48 | $this->assertSame('name', $prop->getProperty()->getName()); |
47 | 49 | $this->assertSame('123', $prop->getAnnotation()->id); |
@@ -55,7 +57,8 @@ discard block |
||
55 | 57 | |
56 | 58 | $this->assertCount(1, $methods); |
57 | 59 | |
58 | - foreach ($methods as $m) { |
|
60 | + foreach ($methods as $m) |
|
61 | + { |
|
59 | 62 | $this->assertSame(TestClass::class, $m->getClass()->getName()); |
60 | 63 | $this->assertSame('testMethod', $m->getMethod()->getName()); |
61 | 64 | $this->assertSame('/', $m->getAnnotation()->path); |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | $input = clone $this; |
39 | 39 | |
40 | 40 | $namespace = trim($namespace); |
41 | - if ($namespace === '') { |
|
41 | + if ($namespace === ''){ |
|
42 | 42 | return $input; |
43 | 43 | } |
44 | 44 | |
45 | 45 | $input->data = []; |
46 | 46 | |
47 | 47 | $data = $this->getValue($namespace, []); |
48 | - if (is_array($data)) { |
|
48 | + if (is_array($data)){ |
|
49 | 49 | $input->data = $data; |
50 | 50 | } |
51 | 51 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function getValue(string $option, $default = null) |
59 | 59 | { |
60 | - if (!$this->hasValue($option)) { |
|
60 | + if (!$this->hasValue($option)){ |
|
61 | 61 | return $default; |
62 | 62 | } |
63 | 63 |
@@ -38,14 +38,16 @@ discard block |
||
38 | 38 | $input = clone $this; |
39 | 39 | |
40 | 40 | $namespace = trim($namespace); |
41 | - if ($namespace === '') { |
|
41 | + if ($namespace === '') |
|
42 | + { |
|
42 | 43 | return $input; |
43 | 44 | } |
44 | 45 | |
45 | 46 | $input->data = []; |
46 | 47 | |
47 | 48 | $data = $this->getValue($namespace, []); |
48 | - if (is_array($data)) { |
|
49 | + if (is_array($data)) |
|
50 | + { |
|
49 | 51 | $input->data = $data; |
50 | 52 | } |
51 | 53 | |
@@ -57,7 +59,8 @@ discard block |
||
57 | 59 | */ |
58 | 60 | public function getValue(string $option, $default = null) |
59 | 61 | { |
60 | - if (!$this->hasValue($option)) { |
|
62 | + if (!$this->hasValue($option)) |
|
63 | + { |
|
61 | 64 | return $default; |
62 | 65 | } |
63 | 66 |
@@ -103,11 +103,11 @@ discard block |
||
103 | 103 | $view = clone $this->view; |
104 | 104 | |
105 | 105 | $filters = []; |
106 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
107 | - if ($schema->hasFilter($name)) { |
|
106 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value){ |
|
107 | + if ($schema->hasFilter($name)){ |
|
108 | 108 | $filter = $schema->getFilter($name)->withValue($value); |
109 | 109 | |
110 | - if ($filter !== null) { |
|
110 | + if ($filter !== null){ |
|
111 | 111 | $source = $this->compiler->compile($source, $filter); |
112 | 112 | $filters[$name] = $filter->getValue(); |
113 | 113 | } |
@@ -115,16 +115,16 @@ discard block |
||
115 | 115 | } |
116 | 116 | $view = $view->withOption(GridInterface::FILTERS, $filters); |
117 | 117 | |
118 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
118 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)){ |
|
119 | 119 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
120 | 120 | } |
121 | 121 | |
122 | 122 | $sorters = []; |
123 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
124 | - if ($schema->hasSorter($name)) { |
|
123 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value){ |
|
124 | + if ($schema->hasSorter($name)){ |
|
125 | 125 | $sorter = $schema->getSorter($name)->withDirection($value); |
126 | 126 | |
127 | - if ($sorter !== null) { |
|
127 | + if ($sorter !== null){ |
|
128 | 128 | $source = $this->compiler->compile($source, $sorter); |
129 | 129 | $sorters[$name] = $sorter->getValue(); |
130 | 130 | } |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | } |
133 | 133 | $view = $view->withOption(GridInterface::SORTERS, $sorters); |
134 | 134 | |
135 | - if ($schema->getPaginator() !== null) { |
|
135 | + if ($schema->getPaginator() !== null){ |
|
136 | 136 | $paginator = $schema->getPaginator()->withValue($this->getOption(static::KEY_PAGINATE)); |
137 | - if ($paginator === null) { |
|
137 | + if ($paginator === null){ |
|
138 | 138 | throw new CompilerException('The paginator can not be null'); |
139 | 139 | } |
140 | 140 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator->getValue()); |
143 | 143 | } |
144 | 144 | |
145 | - if (!is_iterable($source)) { |
|
145 | + if (!is_iterable($source)){ |
|
146 | 146 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
147 | 147 | } |
148 | 148 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | private function getOptionArray(string $option): array |
159 | 159 | { |
160 | 160 | $result = $this->getOption($option); |
161 | - if (!is_array($result)) { |
|
161 | + if (!is_array($result)){ |
|
162 | 162 | return []; |
163 | 163 | } |
164 | 164 | |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | */ |
174 | 174 | private function getOption(string $option) |
175 | 175 | { |
176 | - if ($this->input->hasValue($option)) { |
|
176 | + if ($this->input->hasValue($option)){ |
|
177 | 177 | return $this->input->getValue($option); |
178 | 178 | } |
179 | 179 |
@@ -103,11 +103,14 @@ discard block |
||
103 | 103 | $view = clone $this->view; |
104 | 104 | |
105 | 105 | $filters = []; |
106 | - foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) { |
|
107 | - if ($schema->hasFilter($name)) { |
|
106 | + foreach ($this->getOptionArray(static::KEY_FILTER) ?? [] as $name => $value) |
|
107 | + { |
|
108 | + if ($schema->hasFilter($name)) |
|
109 | + { |
|
108 | 110 | $filter = $schema->getFilter($name)->withValue($value); |
109 | 111 | |
110 | - if ($filter !== null) { |
|
112 | + if ($filter !== null) |
|
113 | + { |
|
111 | 114 | $source = $this->compiler->compile($source, $filter); |
112 | 115 | $filters[$name] = $filter->getValue(); |
113 | 116 | } |
@@ -115,16 +118,20 @@ discard block |
||
115 | 118 | } |
116 | 119 | $view = $view->withOption(GridInterface::FILTERS, $filters); |
117 | 120 | |
118 | - if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) { |
|
121 | + if (is_countable($source) && $this->getOption(static::KEY_FETCH_COUNT)) |
|
122 | + { |
|
119 | 123 | $view = $view->withOption(GridInterface::COUNT, ($this->count)($source)); |
120 | 124 | } |
121 | 125 | |
122 | 126 | $sorters = []; |
123 | - foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) { |
|
124 | - if ($schema->hasSorter($name)) { |
|
127 | + foreach ($this->getOptionArray(static::KEY_SORT) ?? [] as $name => $value) |
|
128 | + { |
|
129 | + if ($schema->hasSorter($name)) |
|
130 | + { |
|
125 | 131 | $sorter = $schema->getSorter($name)->withDirection($value); |
126 | 132 | |
127 | - if ($sorter !== null) { |
|
133 | + if ($sorter !== null) |
|
134 | + { |
|
128 | 135 | $source = $this->compiler->compile($source, $sorter); |
129 | 136 | $sorters[$name] = $sorter->getValue(); |
130 | 137 | } |
@@ -132,9 +139,11 @@ discard block |
||
132 | 139 | } |
133 | 140 | $view = $view->withOption(GridInterface::SORTERS, $sorters); |
134 | 141 | |
135 | - if ($schema->getPaginator() !== null) { |
|
142 | + if ($schema->getPaginator() !== null) |
|
143 | + { |
|
136 | 144 | $paginator = $schema->getPaginator()->withValue($this->getOption(static::KEY_PAGINATE)); |
137 | - if ($paginator === null) { |
|
145 | + if ($paginator === null) |
|
146 | + { |
|
138 | 147 | throw new CompilerException('The paginator can not be null'); |
139 | 148 | } |
140 | 149 | |
@@ -142,7 +151,8 @@ discard block |
||
142 | 151 | $view = $view->withOption(GridInterface::PAGINATOR, $paginator->getValue()); |
143 | 152 | } |
144 | 153 | |
145 | - if (!is_iterable($source)) { |
|
154 | + if (!is_iterable($source)) |
|
155 | + { |
|
146 | 156 | throw new GridViewException('GridView expects the source to be iterable after all.'); |
147 | 157 | } |
148 | 158 | |
@@ -158,7 +168,8 @@ discard block |
||
158 | 168 | private function getOptionArray(string $option): array |
159 | 169 | { |
160 | 170 | $result = $this->getOption($option); |
161 | - if (!is_array($result)) { |
|
171 | + if (!is_array($result)) |
|
172 | + { |
|
162 | 173 | return []; |
163 | 174 | } |
164 | 175 | |
@@ -173,7 +184,8 @@ discard block |
||
173 | 184 | */ |
174 | 185 | private function getOption(string $option) |
175 | 186 | { |
176 | - if ($this->input->hasValue($option)) { |
|
187 | + if ($this->input->hasValue($option)) |
|
188 | + { |
|
177 | 189 | return $this->input->getValue($option); |
178 | 190 | } |
179 | 191 |
@@ -40,7 +40,7 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function addFilter(string $name, FilterInterface $filter): void |
42 | 42 | { |
43 | - if ($this->hasFilter($name)) { |
|
43 | + if ($this->hasFilter($name)){ |
|
44 | 44 | throw new SchemaException("Filter `$name` is already defined"); |
45 | 45 | } |
46 | 46 | |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function getFilter(string $name): FilterInterface |
67 | 67 | { |
68 | - if (!$this->hasFilter($name)) { |
|
68 | + if (!$this->hasFilter($name)){ |
|
69 | 69 | throw new SchemaException("No such filter `$name`"); |
70 | 70 | } |
71 | 71 | |
@@ -89,7 +89,7 @@ discard block |
||
89 | 89 | */ |
90 | 90 | public function addSorter(string $name, SorterInterface $sorter): void |
91 | 91 | { |
92 | - if ($this->hasSorter($name)) { |
|
92 | + if ($this->hasSorter($name)){ |
|
93 | 93 | throw new SchemaException("Sorter `$name` is already defined"); |
94 | 94 | } |
95 | 95 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function getSorter(string $name): SorterInterface |
116 | 116 | { |
117 | - if (!$this->hasSorter($name)) { |
|
117 | + if (!$this->hasSorter($name)){ |
|
118 | 118 | throw new SchemaException("No such sorter `$name`"); |
119 | 119 | } |
120 | 120 |
@@ -40,7 +40,8 @@ discard block |
||
40 | 40 | */ |
41 | 41 | public function addFilter(string $name, FilterInterface $filter): void |
42 | 42 | { |
43 | - if ($this->hasFilter($name)) { |
|
43 | + if ($this->hasFilter($name)) |
|
44 | + { |
|
44 | 45 | throw new SchemaException("Filter `$name` is already defined"); |
45 | 46 | } |
46 | 47 | |
@@ -65,7 +66,8 @@ discard block |
||
65 | 66 | */ |
66 | 67 | public function getFilter(string $name): FilterInterface |
67 | 68 | { |
68 | - if (!$this->hasFilter($name)) { |
|
69 | + if (!$this->hasFilter($name)) |
|
70 | + { |
|
69 | 71 | throw new SchemaException("No such filter `$name`"); |
70 | 72 | } |
71 | 73 | |
@@ -89,7 +91,8 @@ discard block |
||
89 | 91 | */ |
90 | 92 | public function addSorter(string $name, SorterInterface $sorter): void |
91 | 93 | { |
92 | - if ($this->hasSorter($name)) { |
|
94 | + if ($this->hasSorter($name)) |
|
95 | + { |
|
93 | 96 | throw new SchemaException("Sorter `$name` is already defined"); |
94 | 97 | } |
95 | 98 | |
@@ -114,7 +117,8 @@ discard block |
||
114 | 117 | */ |
115 | 118 | public function getSorter(string $name): SorterInterface |
116 | 119 | { |
117 | - if (!$this->hasSorter($name)) { |
|
120 | + if (!$this->hasSorter($name)) |
|
121 | + { |
|
118 | 122 | throw new SchemaException("No such sorter `$name`"); |
119 | 123 | } |
120 | 124 |
@@ -36,7 +36,7 @@ |
||
36 | 36 | $sorter = clone $this; |
37 | 37 | $sorter->sorters = []; |
38 | 38 | |
39 | - foreach ($this->sorters as $s) { |
|
39 | + foreach ($this->sorters as $s){ |
|
40 | 40 | $sorter->sorters[] = $s->withDirection($direction); |
41 | 41 | } |
42 | 42 |
@@ -36,7 +36,8 @@ |
||
36 | 36 | $sorter = clone $this; |
37 | 37 | $sorter->sorters = []; |
38 | 38 | |
39 | - foreach ($this->sorters as $s) { |
|
39 | + foreach ($this->sorters as $s) |
|
40 | + { |
|
40 | 41 | $sorter->sorters[] = $s->withDirection($direction); |
41 | 42 | } |
42 | 43 |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | $sorter = clone $this; |
48 | 48 | $sorter->direction = $sorter->checkDirection($direction); |
49 | 49 | |
50 | - switch ($sorter->direction) { |
|
50 | + switch ($sorter->direction){ |
|
51 | 51 | case self::ASC: |
52 | 52 | $sorter->sorter = $sorter->asc->withDirection(self::ASC); |
53 | 53 | break; |
@@ -76,21 +76,21 @@ discard block |
||
76 | 76 | */ |
77 | 77 | private function checkDirection($direction): ?string |
78 | 78 | { |
79 | - if (is_string($direction)) { |
|
80 | - if (strtolower($direction) === self::DESC) { |
|
79 | + if (is_string($direction)){ |
|
80 | + if (strtolower($direction) === self::DESC){ |
|
81 | 81 | return self::DESC; |
82 | 82 | } |
83 | 83 | |
84 | - if (strtolower($direction) === self::ASC) { |
|
84 | + if (strtolower($direction) === self::ASC){ |
|
85 | 85 | return self::ASC; |
86 | 86 | } |
87 | 87 | } |
88 | 88 | |
89 | - if (in_array($direction, ['-1', -1, SORT_DESC], true)) { |
|
89 | + if (in_array($direction, ['-1', -1, SORT_DESC], true)){ |
|
90 | 90 | return self::DESC; |
91 | 91 | } |
92 | 92 | |
93 | - if (in_array($direction, ['1', 1, SORT_ASC], true)) { |
|
93 | + if (in_array($direction, ['1', 1, SORT_ASC], true)){ |
|
94 | 94 | return self::ASC; |
95 | 95 | } |
96 | 96 |
@@ -47,7 +47,8 @@ discard block |
||
47 | 47 | $sorter = clone $this; |
48 | 48 | $sorter->direction = $sorter->checkDirection($direction); |
49 | 49 | |
50 | - switch ($sorter->direction) { |
|
50 | + switch ($sorter->direction) |
|
51 | + { |
|
51 | 52 | case self::ASC: |
52 | 53 | $sorter->sorter = $sorter->asc->withDirection(self::ASC); |
53 | 54 | break; |
@@ -76,21 +77,26 @@ discard block |
||
76 | 77 | */ |
77 | 78 | private function checkDirection($direction): ?string |
78 | 79 | { |
79 | - if (is_string($direction)) { |
|
80 | - if (strtolower($direction) === self::DESC) { |
|
80 | + if (is_string($direction)) |
|
81 | + { |
|
82 | + if (strtolower($direction) === self::DESC) |
|
83 | + { |
|
81 | 84 | return self::DESC; |
82 | 85 | } |
83 | 86 | |
84 | - if (strtolower($direction) === self::ASC) { |
|
87 | + if (strtolower($direction) === self::ASC) |
|
88 | + { |
|
85 | 89 | return self::ASC; |
86 | 90 | } |
87 | 91 | } |
88 | 92 | |
89 | - if (in_array($direction, ['-1', -1, SORT_DESC], true)) { |
|
93 | + if (in_array($direction, ['-1', -1, SORT_DESC], true)) |
|
94 | + { |
|
90 | 95 | return self::DESC; |
91 | 96 | } |
92 | 97 | |
93 | - if (in_array($direction, ['1', 1, SORT_ASC], true)) { |
|
98 | + if (in_array($direction, ['1', 1, SORT_ASC], true)) |
|
99 | + { |
|
94 | 100 | return self::ASC; |
95 | 101 | } |
96 | 102 |