Passed
Pull Request — master (#370)
by Valentin
04:51
created
src/DataGridBridge/src/Response/GridResponse.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function jsonSerialize(): array
47 47
     {
48
-        if ($this->grid === null) {
48
+        if ($this->grid === null){
49 49
             return [
50 50
                 'status' => 500,
51 51
                 'error'  => 'missing-grid-source',
@@ -57,11 +57,11 @@  discard block
 block discarded – undo
57 57
             $this->option('property', 'data') => $this->data,
58 58
         ];
59 59
 
60
-        if ($this->grid->getOption(GridInterface::PAGINATOR) !== null) {
60
+        if ($this->grid->getOption(GridInterface::PAGINATOR) !== null){
61 61
             $response['pagination'] = $this->grid->getOption(GridInterface::PAGINATOR);
62 62
         }
63 63
 
64
-        if (isset($response['pagination']) && $this->grid->getOption(GridInterface::COUNT) !== null) {
64
+        if (isset($response['pagination']) && $this->grid->getOption(GridInterface::COUNT) !== null){
65 65
             $response['pagination']['count'] = $this->grid->getOption(GridInterface::COUNT);
66 66
         }
67 67
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -45,7 +45,8 @@  discard block
 block discarded – undo
45 45
      */
46 46
     public function jsonSerialize(): array
47 47
     {
48
-        if ($this->grid === null) {
48
+        if ($this->grid === null)
49
+        {
49 50
             return [
50 51
                 'status' => 500,
51 52
                 'error'  => 'missing-grid-source',
@@ -57,11 +58,13 @@  discard block
 block discarded – undo
57 58
             $this->option('property', 'data') => $this->data,
58 59
         ];
59 60
 
60
-        if ($this->grid->getOption(GridInterface::PAGINATOR) !== null) {
61
+        if ($this->grid->getOption(GridInterface::PAGINATOR) !== null)
62
+        {
61 63
             $response['pagination'] = $this->grid->getOption(GridInterface::PAGINATOR);
62 64
         }
63 65
 
64
-        if (isset($response['pagination']) && $this->grid->getOption(GridInterface::COUNT) !== null) {
66
+        if (isset($response['pagination']) && $this->grid->getOption(GridInterface::COUNT) !== null)
67
+        {
65 68
             $response['pagination']['count'] = $this->grid->getOption(GridInterface::COUNT);
66 69
         }
67 70
 
Please login to merge, or discard this patch.
src/DataGridBridge/src/Writer/QueryWriter.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -52,23 +52,23 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function write($source, SpecificationInterface $specification, Compiler $compiler)
54 54
     {
55
-        if (!$this->targetAcceptable($source)) {
55
+        if (!$this->targetAcceptable($source)){
56 56
             return null;
57 57
         }
58 58
 
59
-        if ($specification instanceof Specification\FilterInterface) {
59
+        if ($specification instanceof Specification\FilterInterface){
60 60
             return $this->writeFilter($source, $specification, $compiler);
61 61
         }
62 62
 
63
-        if ($specification instanceof Specification\SorterInterface) {
63
+        if ($specification instanceof Specification\SorterInterface){
64 64
             return $this->writeSorter($source, $specification, $compiler);
65 65
         }
66 66
 
67
-        if ($specification instanceof Specification\Pagination\Limit) {
67
+        if ($specification instanceof Specification\Pagination\Limit){
68 68
             return $source->limit($specification->getValue());
69 69
         }
70 70
 
71
-        if ($specification instanceof Specification\Pagination\Offset) {
71
+        if ($specification instanceof Specification\Pagination\Offset){
72 72
             return $source->offset($specification->getValue());
73 73
         }
74 74
 
@@ -83,15 +83,15 @@  discard block
 block discarded – undo
83 83
      */
84 84
     protected function writeFilter($source, Specification\FilterInterface $filter, Compiler $compiler)
85 85
     {
86
-        if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map) {
86
+        if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map){
87 87
             return $source->where(static function () use ($compiler, $filter, $source): void {
88 88
                 $compiler->compile($source, ...$filter->getFilters());
89 89
             });
90 90
         }
91 91
 
92
-        if ($filter instanceof Specification\Filter\Any) {
92
+        if ($filter instanceof Specification\Filter\Any){
93 93
             return $source->where(static function () use ($compiler, $filter, $source): void {
94
-                foreach ($filter->getFilters() as $subFilter) {
94
+                foreach ($filter->getFilters() as $subFilter){
95 95
                     $source->orWhere(static function () use ($compiler, $subFilter, $source): void {
96 96
                         $compiler->compile($source, $subFilter);
97 97
                     });
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
             });
100 100
         }
101 101
 
102
-        if ($filter instanceof Specification\Filter\InjectionFilter) {
102
+        if ($filter instanceof Specification\Filter\InjectionFilter){
103 103
             $expression = $filter->getFilter();
104
-            if ($expression instanceof Specification\Filter\Expression) {
104
+            if ($expression instanceof Specification\Filter\Expression){
105 105
                 return $source->where(
106 106
                     $filter->getInjection(),
107 107
                     $this->getExpressionOperator($expression),
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
             }
111 111
         }
112 112
 
113
-        if ($filter instanceof Specification\Filter\Expression) {
113
+        if ($filter instanceof Specification\Filter\Expression){
114 114
             return $source->where(
115 115
                 $filter->getExpression(),
116 116
                 $this->getExpressionOperator($filter),
@@ -127,11 +127,11 @@  discard block
 block discarded – undo
127 127
      */
128 128
     protected function getExpressionOperator(Specification\Filter\Expression $filter): string
129 129
     {
130
-        if ($filter instanceof Specification\Filter\Like) {
130
+        if ($filter instanceof Specification\Filter\Like){
131 131
             return 'LIKE';
132 132
         }
133 133
 
134
-        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) {
134
+        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray){
135 135
             return self::ARRAY_OPERATORS[get_class($filter)];
136 136
         }
137 137
 
@@ -144,11 +144,11 @@  discard block
 block discarded – undo
144 144
      */
145 145
     protected function getExpressionArgs(Specification\Filter\Expression $filter): array
146 146
     {
147
-        if ($filter instanceof Specification\Filter\Like) {
147
+        if ($filter instanceof Specification\Filter\Like){
148 148
             return [sprintf($filter->getPattern(), $this->fetchValue($filter->getValue()))];
149 149
         }
150 150
 
151
-        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) {
151
+        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray){
152 152
             return [new Parameter($this->fetchValue($filter->getValue()))];
153 153
         }
154 154
 
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
      */
164 164
     protected function writeSorter($source, Specification\SorterInterface $sorter, Compiler $compiler)
165 165
     {
166
-        if ($sorter instanceof Specification\Sorter\SorterSet) {
167
-            foreach ($sorter->getSorters() as $subSorter) {
166
+        if ($sorter instanceof Specification\Sorter\SorterSet){
167
+            foreach ($sorter->getSorters() as $subSorter){
168 168
                 $source = $compiler->compile($source, $subSorter);
169 169
             }
170 170
 
@@ -174,9 +174,9 @@  discard block
 block discarded – undo
174 174
         if (
175 175
             $sorter instanceof Specification\Sorter\AscSorter
176 176
             || $sorter instanceof Specification\Sorter\DescSorter
177
-        ) {
177
+        ){
178 178
             $direction = static::SORTER_DIRECTIONS[get_class($sorter)];
179
-            foreach ($sorter->getExpressions() as $expression) {
179
+            foreach ($sorter->getExpressions() as $expression){
180 180
                 $source = $source->orderBy($expression, $direction);
181 181
             }
182 182
 
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
      */
195 195
     protected function fetchValue($value)
196 196
     {
197
-        if ($value instanceof Specification\ValueInterface) {
197
+        if ($value instanceof Specification\ValueInterface){
198 198
             throw new CompilerException('Value expects user input, none given');
199 199
         }
200 200
 
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
      */
208 208
     protected function targetAcceptable($target): bool
209 209
     {
210
-        if (class_exists(SelectQuery::class) && $target instanceof SelectQuery) {
210
+        if (class_exists(SelectQuery::class) && $target instanceof SelectQuery){
211 211
             return true;
212 212
         }
213 213
 
214
-        if (class_exists(Select::class) && $target instanceof Select) {
214
+        if (class_exists(Select::class) && $target instanceof Select){
215 215
             return true;
216 216
         }
217 217
 
Please login to merge, or discard this patch.
Braces   +42 added lines, -21 removed lines patch added patch discarded remove patch
@@ -52,23 +52,28 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function write($source, SpecificationInterface $specification, Compiler $compiler)
54 54
     {
55
-        if (!$this->targetAcceptable($source)) {
55
+        if (!$this->targetAcceptable($source))
56
+        {
56 57
             return null;
57 58
         }
58 59
 
59
-        if ($specification instanceof Specification\FilterInterface) {
60
+        if ($specification instanceof Specification\FilterInterface)
61
+        {
60 62
             return $this->writeFilter($source, $specification, $compiler);
61 63
         }
62 64
 
63
-        if ($specification instanceof Specification\SorterInterface) {
65
+        if ($specification instanceof Specification\SorterInterface)
66
+        {
64 67
             return $this->writeSorter($source, $specification, $compiler);
65 68
         }
66 69
 
67
-        if ($specification instanceof Specification\Pagination\Limit) {
70
+        if ($specification instanceof Specification\Pagination\Limit)
71
+        {
68 72
             return $source->limit($specification->getValue());
69 73
         }
70 74
 
71
-        if ($specification instanceof Specification\Pagination\Offset) {
75
+        if ($specification instanceof Specification\Pagination\Offset)
76
+        {
72 77
             return $source->offset($specification->getValue());
73 78
         }
74 79
 
@@ -83,15 +88,18 @@  discard block
 block discarded – undo
83 88
      */
84 89
     protected function writeFilter($source, Specification\FilterInterface $filter, Compiler $compiler)
85 90
     {
86
-        if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map) {
91
+        if ($filter instanceof Specification\Filter\All || $filter instanceof Specification\Filter\Map)
92
+        {
87 93
             return $source->where(static function () use ($compiler, $filter, $source): void {
88 94
                 $compiler->compile($source, ...$filter->getFilters());
89 95
             });
90 96
         }
91 97
 
92
-        if ($filter instanceof Specification\Filter\Any) {
98
+        if ($filter instanceof Specification\Filter\Any)
99
+        {
93 100
             return $source->where(static function () use ($compiler, $filter, $source): void {
94
-                foreach ($filter->getFilters() as $subFilter) {
101
+                foreach ($filter->getFilters() as $subFilter)
102
+                {
95 103
                     $source->orWhere(static function () use ($compiler, $subFilter, $source): void {
96 104
                         $compiler->compile($source, $subFilter);
97 105
                     });
@@ -99,9 +107,11 @@  discard block
 block discarded – undo
99 107
             });
100 108
         }
101 109
 
102
-        if ($filter instanceof Specification\Filter\InjectionFilter) {
110
+        if ($filter instanceof Specification\Filter\InjectionFilter)
111
+        {
103 112
             $expression = $filter->getFilter();
104
-            if ($expression instanceof Specification\Filter\Expression) {
113
+            if ($expression instanceof Specification\Filter\Expression)
114
+            {
105 115
                 return $source->where(
106 116
                     $filter->getInjection(),
107 117
                     $this->getExpressionOperator($expression),
@@ -110,7 +120,8 @@  discard block
 block discarded – undo
110 120
             }
111 121
         }
112 122
 
113
-        if ($filter instanceof Specification\Filter\Expression) {
123
+        if ($filter instanceof Specification\Filter\Expression)
124
+        {
114 125
             return $source->where(
115 126
                 $filter->getExpression(),
116 127
                 $this->getExpressionOperator($filter),
@@ -127,11 +138,13 @@  discard block
 block discarded – undo
127 138
      */
128 139
     protected function getExpressionOperator(Specification\Filter\Expression $filter): string
129 140
     {
130
-        if ($filter instanceof Specification\Filter\Like) {
141
+        if ($filter instanceof Specification\Filter\Like)
142
+        {
131 143
             return 'LIKE';
132 144
         }
133 145
 
134
-        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) {
146
+        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray)
147
+        {
135 148
             return self::ARRAY_OPERATORS[get_class($filter)];
136 149
         }
137 150
 
@@ -144,11 +157,13 @@  discard block
 block discarded – undo
144 157
      */
145 158
     protected function getExpressionArgs(Specification\Filter\Expression $filter): array
146 159
     {
147
-        if ($filter instanceof Specification\Filter\Like) {
160
+        if ($filter instanceof Specification\Filter\Like)
161
+        {
148 162
             return [sprintf($filter->getPattern(), $this->fetchValue($filter->getValue()))];
149 163
         }
150 164
 
151
-        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray) {
165
+        if ($filter instanceof Specification\Filter\InArray || $filter instanceof Specification\Filter\NotInArray)
166
+        {
152 167
             return [new Parameter($this->fetchValue($filter->getValue()))];
153 168
         }
154 169
 
@@ -163,8 +178,10 @@  discard block
 block discarded – undo
163 178
      */
164 179
     protected function writeSorter($source, Specification\SorterInterface $sorter, Compiler $compiler)
165 180
     {
166
-        if ($sorter instanceof Specification\Sorter\SorterSet) {
167
-            foreach ($sorter->getSorters() as $subSorter) {
181
+        if ($sorter instanceof Specification\Sorter\SorterSet)
182
+        {
183
+            foreach ($sorter->getSorters() as $subSorter)
184
+            {
168 185
                 $source = $compiler->compile($source, $subSorter);
169 186
             }
170 187
 
@@ -176,7 +193,8 @@  discard block
 block discarded – undo
176 193
             || $sorter instanceof Specification\Sorter\DescSorter
177 194
         ) {
178 195
             $direction = static::SORTER_DIRECTIONS[get_class($sorter)];
179
-            foreach ($sorter->getExpressions() as $expression) {
196
+            foreach ($sorter->getExpressions() as $expression)
197
+            {
180 198
                 $source = $source->orderBy($expression, $direction);
181 199
             }
182 200
 
@@ -194,7 +212,8 @@  discard block
 block discarded – undo
194 212
      */
195 213
     protected function fetchValue($value)
196 214
     {
197
-        if ($value instanceof Specification\ValueInterface) {
215
+        if ($value instanceof Specification\ValueInterface)
216
+        {
198 217
             throw new CompilerException('Value expects user input, none given');
199 218
         }
200 219
 
@@ -207,11 +226,13 @@  discard block
 block discarded – undo
207 226
      */
208 227
     protected function targetAcceptable($target): bool
209 228
     {
210
-        if (class_exists(SelectQuery::class) && $target instanceof SelectQuery) {
229
+        if (class_exists(SelectQuery::class) && $target instanceof SelectQuery)
230
+        {
211 231
             return true;
212 232
         }
213 233
 
214
-        if (class_exists(Select::class) && $target instanceof Select) {
234
+        if (class_exists(Select::class) && $target instanceof Select)
235
+        {
215 236
             return true;
216 237
         }
217 238
 
Please login to merge, or discard this patch.
src/DataGridBridge/src/Writer/BetweenWriter.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,20 +35,20 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function write($source, SpecificationInterface $specification, Compiler $compiler)
37 37
     {
38
-        if ($specification instanceof Filter\Between || $specification instanceof Filter\ValueBetween) {
38
+        if ($specification instanceof Filter\Between || $specification instanceof Filter\ValueBetween){
39 39
             $filters = $specification->getFilters($this->asOriginal);
40
-            if (count($filters) > 1) {
40
+            if (count($filters) > 1){
41 41
                 return $source->where(static function () use ($compiler, $source, $filters): void {
42 42
                     $compiler->compile($source, ...$filters);
43 43
                 });
44 44
             }
45 45
         }
46 46
 
47
-        if ($specification instanceof Filter\InjectionFilter) {
47
+        if ($specification instanceof Filter\InjectionFilter){
48 48
             $expression = $specification->getFilter();
49
-            if ($expression instanceof Filter\Between) {
49
+            if ($expression instanceof Filter\Between){
50 50
                 $filters = $expression->getFilters($this->asOriginal);
51
-                if (count($filters) > 1) {
51
+                if (count($filters) > 1){
52 52
                     $filters = array_map(
53 53
                         static function (SpecificationInterface $filter) use ($specification): Filter\InjectionFilter {
54 54
                             return Filter\InjectionFilter::createFrom($specification, $filter);
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
             }
72 72
         }
73 73
 
74
-        if ($specification instanceof Filter\Between) {
74
+        if ($specification instanceof Filter\Between){
75 75
             return $source->where(
76 76
                 $specification->getExpression(),
77 77
                 'BETWEEN',
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
             );
80 80
         }
81 81
 
82
-        if ($specification instanceof Filter\ValueBetween) {
82
+        if ($specification instanceof Filter\ValueBetween){
83 83
             return $source->where(
84 84
                 new Parameter($specification->getValue()),
85 85
                 'BETWEEN',
Please login to merge, or discard this patch.
Braces   +14 added lines, -7 removed lines patch added patch discarded remove patch
@@ -35,20 +35,25 @@  discard block
 block discarded – undo
35 35
      */
36 36
     public function write($source, SpecificationInterface $specification, Compiler $compiler)
37 37
     {
38
-        if ($specification instanceof Filter\Between || $specification instanceof Filter\ValueBetween) {
38
+        if ($specification instanceof Filter\Between || $specification instanceof Filter\ValueBetween)
39
+        {
39 40
             $filters = $specification->getFilters($this->asOriginal);
40
-            if (count($filters) > 1) {
41
+            if (count($filters) > 1)
42
+            {
41 43
                 return $source->where(static function () use ($compiler, $source, $filters): void {
42 44
                     $compiler->compile($source, ...$filters);
43 45
                 });
44 46
             }
45 47
         }
46 48
 
47
-        if ($specification instanceof Filter\InjectionFilter) {
49
+        if ($specification instanceof Filter\InjectionFilter)
50
+        {
48 51
             $expression = $specification->getFilter();
49
-            if ($expression instanceof Filter\Between) {
52
+            if ($expression instanceof Filter\Between)
53
+            {
50 54
                 $filters = $expression->getFilters($this->asOriginal);
51
-                if (count($filters) > 1) {
55
+                if (count($filters) > 1)
56
+                {
52 57
                     $filters = array_map(
53 58
                         static function (SpecificationInterface $filter) use ($specification): Filter\InjectionFilter {
54 59
                             return Filter\InjectionFilter::createFrom($specification, $filter);
@@ -71,7 +76,8 @@  discard block
 block discarded – undo
71 76
             }
72 77
         }
73 78
 
74
-        if ($specification instanceof Filter\Between) {
79
+        if ($specification instanceof Filter\Between)
80
+        {
75 81
             return $source->where(
76 82
                 $specification->getExpression(),
77 83
                 'BETWEEN',
@@ -79,7 +85,8 @@  discard block
 block discarded – undo
79 85
             );
80 86
         }
81 87
 
82
-        if ($specification instanceof Filter\ValueBetween) {
88
+        if ($specification instanceof Filter\ValueBetween)
89
+        {
83 90
             return $source->where(
84 91
                 new Parameter($specification->getValue()),
85 92
                 'BETWEEN',
Please login to merge, or discard this patch.
src/DataGridBridge/src/Bootloader/GridBootloader.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,8 @@
 block discarded – undo
66 66
      */
67 67
     public function compiler(ContainerInterface $container, Compiler $compiler, GridConfig $config): Compiler
68 68
     {
69
-        if ($container->has(DatabaseInterface::class)) {
70
-            foreach ($config->getWriters() as $writer) {
69
+        if ($container->has(DatabaseInterface::class)){
70
+            foreach ($config->getWriters() as $writer){
71 71
                 $compiler->addWriter($container->get($writer));
72 72
             }
73 73
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -66,8 +66,10 @@
 block discarded – undo
66 66
      */
67 67
     public function compiler(ContainerInterface $container, Compiler $compiler, GridConfig $config): Compiler
68 68
     {
69
-        if ($container->has(DatabaseInterface::class)) {
70
-            foreach ($config->getWriters() as $writer) {
69
+        if ($container->has(DatabaseInterface::class))
70
+        {
71
+            foreach ($config->getWriters() as $writer)
72
+            {
71 73
                 $compiler->addWriter($container->get($writer));
72 74
             }
73 75
         }
Please login to merge, or discard this patch.
src/DataGridBridge/src/Specification/Filter/InjectionFilter.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
 
26 26
     public function __construct(SpecificationInterface $expression)
27 27
     {
28
-        if (!$expression instanceof Expression && !$expression instanceof Between) {
28
+        if (!$expression instanceof Expression && !$expression instanceof Between){
29 29
             throw new LogicException('Only expression filters allowed');
30 30
         }
31 31
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,8 @@
 block discarded – undo
25 25
 
26 26
     public function __construct(SpecificationInterface $expression)
27 27
     {
28
-        if (!$expression instanceof Expression && !$expression instanceof Between) {
28
+        if (!$expression instanceof Expression && !$expression instanceof Between)
29
+        {
29 30
             throw new LogicException('Only expression filters allowed');
30 31
         }
31 32
 
Please login to merge, or discard this patch.
src/DataGridBridge/tests/QueryWriter/WriteSorterTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
             )
117 117
         );
118 118
 
119
-        if ($resultDirection === null) {
119
+        if ($resultDirection === null){
120 120
             $this->assertNull($sorter->withDirection($direction));
121
-        } else {
121
+        }else{
122 122
             $select = $this->compile(
123 123
                 $this->initQuery(),
124 124
                 $sorter->withDirection($direction)
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
     {
177 177
         $sorter = new Sorter\Sorter('balance', 'credits');
178 178
 
179
-        if ($resultDirection === null) {
179
+        if ($resultDirection === null){
180 180
             $this->assertNull($sorter->withDirection($direction));
181
-        } else {
181
+        }else{
182 182
             $select = $this->compile(
183 183
                 $this->initQuery(),
184 184
                 $sorter->withDirection($direction)
Please login to merge, or discard this patch.
Braces   +10 added lines, -4 removed lines patch added patch discarded remove patch
@@ -116,9 +116,12 @@  discard block
 block discarded – undo
116 116
             )
117 117
         );
118 118
 
119
-        if ($resultDirection === null) {
119
+        if ($resultDirection === null)
120
+        {
120 121
             $this->assertNull($sorter->withDirection($direction));
121
-        } else {
122
+        }
123
+        else
124
+        {
122 125
             $select = $this->compile(
123 126
                 $this->initQuery(),
124 127
                 $sorter->withDirection($direction)
@@ -176,9 +179,12 @@  discard block
 block discarded – undo
176 179
     {
177 180
         $sorter = new Sorter\Sorter('balance', 'credits');
178 181
 
179
-        if ($resultDirection === null) {
182
+        if ($resultDirection === null)
183
+        {
180 184
             $this->assertNull($sorter->withDirection($direction));
181
-        } else {
185
+        }
186
+        else
187
+        {
182 188
             $select = $this->compile(
183 189
                 $this->initQuery(),
184 190
                 $sorter->withDirection($direction)
Please login to merge, or discard this patch.
src/DataGridBridge/tests/GeneratorTest.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
                 $this->db->table('users')->select('*'),
131 131
                 $schema
132 132
             )
133
-            ->withView(static function ($u) {
133
+            ->withView(static function ($u){
134 134
                 return $u['name'];
135 135
             });
136 136
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
                 $this->db->table('users')->select('*'),
161 161
                 $schema
162 162
             )
163
-            ->withView(static function ($u) {
163
+            ->withView(static function ($u){
164 164
                 return $u['name'];
165 165
             });
166 166
 
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
                 $this->db->table('users')->select('*'),
190 190
                 $schema
191 191
             )
192
-            ->withView(static function ($u) {
192
+            ->withView(static function ($u){
193 193
                 return $u['name'];
194 194
             });
195 195
 
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
                 $this->db->table('users')->select('*'),
219 219
                 $schema
220 220
             )
221
-            ->withView(static function ($u) {
221
+            ->withView(static function ($u){
222 222
                 return $u['name'];
223 223
             });
224 224
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -130,7 +130,8 @@  discard block
 block discarded – undo
130 130
                 $this->db->table('users')->select('*'),
131 131
                 $schema
132 132
             )
133
-            ->withView(static function ($u) {
133
+            ->withView(static function ($u)
134
+            {
134 135
                 return $u['name'];
135 136
             });
136 137
 
@@ -160,7 +161,8 @@  discard block
 block discarded – undo
160 161
                 $this->db->table('users')->select('*'),
161 162
                 $schema
162 163
             )
163
-            ->withView(static function ($u) {
164
+            ->withView(static function ($u)
165
+            {
164 166
                 return $u['name'];
165 167
             });
166 168
 
@@ -189,7 +191,8 @@  discard block
 block discarded – undo
189 191
                 $this->db->table('users')->select('*'),
190 192
                 $schema
191 193
             )
192
-            ->withView(static function ($u) {
194
+            ->withView(static function ($u)
195
+            {
193 196
                 return $u['name'];
194 197
             });
195 198
 
@@ -218,7 +221,8 @@  discard block
 block discarded – undo
218 221
                 $this->db->table('users')->select('*'),
219 222
                 $schema
220 223
             )
221
-            ->withView(static function ($u) {
224
+            ->withView(static function ($u)
225
+            {
222 226
                 return $u['name'];
223 227
             });
224 228
 
Please login to merge, or discard this patch.
src/Framework/Domain/CycleInterceptor.php 2 patches
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role){
50 50
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
51
+            if ($value === null){
52 52
                 throw new ControllerException(
53 53
                     "Entity `{$parameter}` can not be found",
54 54
                     ControllerException::NOT_FOUND
55 55
                 );
56 56
             }
57 57
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
58
+            if (is_object($value)){
59
+                if ($this->orm->getHeap()->has($value)){
60 60
                     $contextCandidates[] = $value;
61 61
                 }
62 62
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
             }
66 66
 
67 67
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
68
+            if ($entity === null){
69 69
                 throw new ControllerException(
70 70
                     "Entity `{$parameter}` can not be found",
71 71
                     ControllerException::NOT_FOUND
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
             $contextCandidates[] = $entity;
77 77
         }
78 78
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
79
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1){
80 80
             $parameters['@context'] = current($contextCandidates);
81 81
         }
82 82
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 93
     {
94
-        if (!$useDefault) {
94
+        if (!$useDefault){
95 95
             return $parameters[$role] ?? null;
96 96
         }
97 97
 
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
     private function getDeclaredEntities(string $controller, string $action): array
117 117
     {
118 118
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
119
+        if (array_key_exists($key, $this->cache)){
120 120
             return $this->cache[$key];
121 121
         }
122 122
 
123 123
         $this->cache[$key] = [];
124
-        try {
124
+        try{
125 125
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
126
+        }catch (\ReflectionException $e){
127 127
             return [];
128 128
         }
129 129
 
130
-        foreach ($method->getParameters() as $parameter) {
130
+        foreach ($method->getParameters() as $parameter){
131 131
             $class = $this->getParameterClass($parameter);
132 132
 
133
-            if ($class === null) {
133
+            if ($class === null){
134 134
                 continue;
135 135
             }
136 136
 
137
-            if ($this->orm->getSchema()->defines($class->getName())) {
137
+            if ($this->orm->getSchema()->defines($class->getName())){
138 138
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName());
139 139
             }
140 140
         }
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
     {
151 151
         $type = $parameter->getType();
152 152
 
153
-        if (!$type instanceof \ReflectionNamedType) {
153
+        if (!$type instanceof \ReflectionNamedType){
154 154
             return null;
155 155
         }
156 156
 
157
-        if ($type->isBuiltin()) {
157
+        if ($type->isBuiltin()){
158 158
             return null;
159 159
         }
160 160
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -15 removed lines patch added patch discarded remove patch
@@ -46,17 +46,21 @@  discard block
 block discarded – undo
46 46
         $entities = $this->getDeclaredEntities($controller, $action);
47 47
 
48 48
         $contextCandidates = [];
49
-        foreach ($entities as $parameter => $role) {
49
+        foreach ($entities as $parameter => $role)
50
+        {
50 51
             $value = $this->getParameter($parameter, $parameters, count($entities) === 1);
51
-            if ($value === null) {
52
+            if ($value === null)
53
+            {
52 54
                 throw new ControllerException(
53 55
                     "Entity `{$parameter}` can not be found",
54 56
                     ControllerException::NOT_FOUND
55 57
                 );
56 58
             }
57 59
 
58
-            if (is_object($value)) {
59
-                if ($this->orm->getHeap()->has($value)) {
60
+            if (is_object($value))
61
+            {
62
+                if ($this->orm->getHeap()->has($value))
63
+                {
60 64
                     $contextCandidates[] = $value;
61 65
                 }
62 66
 
@@ -65,7 +69,8 @@  discard block
 block discarded – undo
65 69
             }
66 70
 
67 71
             $entity = $this->resolveEntity($role, $value);
68
-            if ($entity === null) {
72
+            if ($entity === null)
73
+            {
69 74
                 throw new ControllerException(
70 75
                     "Entity `{$parameter}` can not be found",
71 76
                     ControllerException::NOT_FOUND
@@ -76,7 +81,8 @@  discard block
 block discarded – undo
76 81
             $contextCandidates[] = $entity;
77 82
         }
78 83
 
79
-        if (!isset($parameters['@context']) && count($contextCandidates) === 1) {
84
+        if (!isset($parameters['@context']) && count($contextCandidates) === 1)
85
+        {
80 86
             $parameters['@context'] = current($contextCandidates);
81 87
         }
82 88
 
@@ -91,7 +97,8 @@  discard block
 block discarded – undo
91 97
      */
92 98
     protected function getParameter(string $role, array $parameters, bool $useDefault = false)
93 99
     {
94
-        if (!$useDefault) {
100
+        if (!$useDefault)
101
+        {
95 102
             return $parameters[$role] ?? null;
96 103
         }
97 104
 
@@ -116,25 +123,32 @@  discard block
 block discarded – undo
116 123
     private function getDeclaredEntities(string $controller, string $action): array
117 124
     {
118 125
         $key = sprintf('%s:%s', $controller, $action);
119
-        if (array_key_exists($key, $this->cache)) {
126
+        if (array_key_exists($key, $this->cache))
127
+        {
120 128
             return $this->cache[$key];
121 129
         }
122 130
 
123 131
         $this->cache[$key] = [];
124
-        try {
132
+        try
133
+        {
125 134
             $method = new \ReflectionMethod($controller, $action);
126
-        } catch (\ReflectionException $e) {
135
+        }
136
+        catch (\ReflectionException $e)
137
+        {
127 138
             return [];
128 139
         }
129 140
 
130
-        foreach ($method->getParameters() as $parameter) {
141
+        foreach ($method->getParameters() as $parameter)
142
+        {
131 143
             $class = $this->getParameterClass($parameter);
132 144
 
133
-            if ($class === null) {
145
+            if ($class === null)
146
+            {
134 147
                 continue;
135 148
             }
136 149
 
137
-            if ($this->orm->getSchema()->defines($class->getName())) {
150
+            if ($this->orm->getSchema()->defines($class->getName()))
151
+            {
138 152
                 $this->cache[$key][$parameter->getName()] = $this->orm->resolveRole($class->getName());
139 153
             }
140 154
         }
@@ -150,11 +164,13 @@  discard block
 block discarded – undo
150 164
     {
151 165
         $type = $parameter->getType();
152 166
 
153
-        if (!$type instanceof \ReflectionNamedType) {
167
+        if (!$type instanceof \ReflectionNamedType)
168
+        {
154 169
             return null;
155 170
         }
156 171
 
157
-        if ($type->isBuiltin()) {
172
+        if ($type->isBuiltin())
173
+        {
158 174
             return null;
159 175
         }
160 176
 
Please login to merge, or discard this patch.
src/Framework/Domain/FilterInterceptor.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,20 +49,20 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass){
53
+            if (isset($parameters[$parameter])){
54 54
                 continue;
55 55
             }
56 56
 
57 57
             /** @var FilterInterface $filter */
58 58
             $filter = $this->container->get($filterClass);
59 59
 
60
-            if (isset($parameters['@context'])) {
60
+            if (isset($parameters['@context'])){
61 61
                 // other interceptors can define the validation contex
62 62
                 $filter->setContext($parameters['@context']);
63 63
             }
64 64
 
65
-            if (!$filter->isValid()) {
65
+            if (!$filter->isValid()){
66 66
                 return $this->renderInvalid($filter);
67 67
             }
68 68
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
      */
81 81
     protected function renderInvalid(FilterInterface $filter)
82 82
     {
83
-        switch ($this->strategy) {
83
+        switch ($this->strategy){
84 84
             case self::STRATEGY_JSON_RESPONSE:
85 85
                 return [
86 86
                     'status' => 400,
@@ -99,25 +99,25 @@  discard block
 block discarded – undo
99 99
     private function getDeclaredFilters(string $controller, string $action): array
100 100
     {
101 101
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
102
+        if (array_key_exists($key, $this->cache)){
103 103
             return $this->cache[$key];
104 104
         }
105 105
 
106 106
         $this->cache[$key] = [];
107
-        try {
107
+        try{
108 108
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
109
+        }catch (\ReflectionException $e){
110 110
             return [];
111 111
         }
112 112
 
113
-        foreach ($method->getParameters() as $parameter) {
113
+        foreach ($method->getParameters() as $parameter){
114 114
             $class = $this->getParameterClass($parameter);
115 115
 
116
-            if ($class === null) {
116
+            if ($class === null){
117 117
                 continue;
118 118
             }
119 119
 
120
-            if ($class->implementsInterface(FilterInterface::class)) {
120
+            if ($class->implementsInterface(FilterInterface::class)){
121 121
                 $this->cache[$key][$parameter->getName()] = $class->getName();
122 122
             }
123 123
         }
@@ -134,11 +134,11 @@  discard block
 block discarded – undo
134 134
     {
135 135
         $type = $parameter->getType();
136 136
 
137
-        if (!$type instanceof \ReflectionNamedType) {
137
+        if (!$type instanceof \ReflectionNamedType){
138 138
             return null;
139 139
         }
140 140
 
141
-        if ($type->isBuiltin()) {
141
+        if ($type->isBuiltin()){
142 142
             return null;
143 143
         }
144 144
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -13 removed lines patch added patch discarded remove patch
@@ -49,20 +49,24 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function process(string $controller, string $action, array $parameters, CoreInterface $core)
51 51
     {
52
-        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass) {
53
-            if (isset($parameters[$parameter])) {
52
+        foreach ($this->getDeclaredFilters($controller, $action) as $parameter => $filterClass)
53
+        {
54
+            if (isset($parameters[$parameter]))
55
+            {
54 56
                 continue;
55 57
             }
56 58
 
57 59
             /** @var FilterInterface $filter */
58 60
             $filter = $this->container->get($filterClass);
59 61
 
60
-            if (isset($parameters['@context'])) {
62
+            if (isset($parameters['@context']))
63
+            {
61 64
                 // other interceptors can define the validation contex
62 65
                 $filter->setContext($parameters['@context']);
63 66
             }
64 67
 
65
-            if (!$filter->isValid()) {
68
+            if (!$filter->isValid())
69
+            {
66 70
                 return $this->renderInvalid($filter);
67 71
             }
68 72
 
@@ -80,7 +84,8 @@  discard block
 block discarded – undo
80 84
      */
81 85
     protected function renderInvalid(FilterInterface $filter)
82 86
     {
83
-        switch ($this->strategy) {
87
+        switch ($this->strategy)
88
+        {
84 89
             case self::STRATEGY_JSON_RESPONSE:
85 90
                 return [
86 91
                     'status' => 400,
@@ -99,25 +104,32 @@  discard block
 block discarded – undo
99 104
     private function getDeclaredFilters(string $controller, string $action): array
100 105
     {
101 106
         $key = sprintf('%s:%s', $controller, $action);
102
-        if (array_key_exists($key, $this->cache)) {
107
+        if (array_key_exists($key, $this->cache))
108
+        {
103 109
             return $this->cache[$key];
104 110
         }
105 111
 
106 112
         $this->cache[$key] = [];
107
-        try {
113
+        try
114
+        {
108 115
             $method = new \ReflectionMethod($controller, $action);
109
-        } catch (\ReflectionException $e) {
116
+        }
117
+        catch (\ReflectionException $e)
118
+        {
110 119
             return [];
111 120
         }
112 121
 
113
-        foreach ($method->getParameters() as $parameter) {
122
+        foreach ($method->getParameters() as $parameter)
123
+        {
114 124
             $class = $this->getParameterClass($parameter);
115 125
 
116
-            if ($class === null) {
126
+            if ($class === null)
127
+            {
117 128
                 continue;
118 129
             }
119 130
 
120
-            if ($class->implementsInterface(FilterInterface::class)) {
131
+            if ($class->implementsInterface(FilterInterface::class))
132
+            {
121 133
                 $this->cache[$key][$parameter->getName()] = $class->getName();
122 134
             }
123 135
         }
@@ -134,11 +146,13 @@  discard block
 block discarded – undo
134 146
     {
135 147
         $type = $parameter->getType();
136 148
 
137
-        if (!$type instanceof \ReflectionNamedType) {
149
+        if (!$type instanceof \ReflectionNamedType)
150
+        {
138 151
             return null;
139 152
         }
140 153
 
141
-        if ($type->isBuiltin()) {
154
+        if ($type->isBuiltin())
155
+        {
142 156
             return null;
143 157
         }
144 158
 
Please login to merge, or discard this patch.