Passed
Pull Request — master (#355)
by Valentin
05:00
created
src/DataGrid/src/Specification/Filter/Any.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
     public function withValue($value): ?SpecificationInterface
32 32
     {
33 33
         $any = $this->clone($value);
34
-        foreach ($this->filters as $filter) {
34
+        foreach ($this->filters as $filter){
35 35
             $applied = $filter->withValue($value);
36 36
 
37
-            if ($applied === null) {
37
+            if ($applied === null){
38 38
                 // all nested filters must be configured
39 39
                 continue;
40 40
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,12 @@
 block discarded – undo
31 31
     public function withValue($value): ?SpecificationInterface
32 32
     {
33 33
         $any = $this->clone($value);
34
-        foreach ($this->filters as $filter) {
34
+        foreach ($this->filters as $filter)
35
+        {
35 36
             $applied = $filter->withValue($value);
36 37
 
37
-            if ($applied === null) {
38
+            if ($applied === null)
39
+            {
38 40
                 // all nested filters must be configured
39 41
                 continue;
40 42
             }
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Filter/ValueBetween.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function __construct($expression, array $value, bool $includeFrom = true, bool $includeTo = true)
39 39
     {
40
-        if (is_array($expression) || (is_object($expression) && !$expression instanceof ValueInterface)) {
40
+        if (is_array($expression) || (is_object($expression) && !$expression instanceof ValueInterface)){
41 41
             throw new ValueException(sprintf(
42 42
                 'Expression expected to be instance of `%s` or a scalar value, got %s.',
43 43
                 ValueInterface::class,
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
             ));
46 46
         }
47 47
 
48
-        if (!$this->isValidArray($value)) {
48
+        if (!$this->isValidArray($value)){
49 49
             throw new ValueException(sprintf(
50 50
                 'Value expected to be an array of 2 different scalar elements, got %s.',
51 51
                 $this->invalidValueType($value)
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
     public function withValue($value): ?SpecificationInterface
67 67
     {
68 68
         $between = clone $this;
69
-        if (!$between->expression instanceof ValueInterface) {
69
+        if (!$between->expression instanceof ValueInterface){
70 70
             //constant value
71 71
             return $between;
72 72
         }
73 73
 
74
-        if (!$between->expression->accepts($value)) {
74
+        if (!$between->expression->accepts($value)){
75 75
             return null;
76 76
         }
77 77
 
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
      */
103 103
     public function getFilters(bool $asOriginal = false): array
104 104
     {
105
-        if ($asOriginal && $this->includeFrom && $this->includeTo) {
105
+        if ($asOriginal && $this->includeFrom && $this->includeTo){
106 106
             return [$this];
107 107
         }
108 108
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
      */
117 117
     private function isValidArray(array $value): bool
118 118
     {
119
-        if (count($value) !== 2) {
119
+        if (count($value) !== 2){
120 120
             return false;
121 121
         }
122 122
 
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
     private function invalidValueType(array $value): string
133 133
     {
134 134
         $count = count($value);
135
-        if ($count === 0) {
135
+        if ($count === 0){
136 136
             return 'empty array';
137 137
         }
138 138
 
139
-        if ($count !== 2) {
139
+        if ($count !== 2){
140 140
             return "array of $count elements";
141 141
         }
142 142
 
143 143
         [$from, $to] = array_values($value);
144
-        if (!is_scalar($from) || !is_scalar($to)) {
144
+        if (!is_scalar($from) || !is_scalar($to)){
145 145
             return 'array of 2 not scalar elements';
146 146
         }
147 147
 
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
      */
155 155
     private function invalidExpressionType($value): string
156 156
     {
157
-        if (is_object($value)) {
157
+        if (is_object($value)){
158 158
             return get_class($value);
159 159
         }
160 160
 
Please login to merge, or discard this patch.
Braces   +20 added lines, -10 removed lines patch added patch discarded remove patch
@@ -37,7 +37,8 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public function __construct($expression, array $value, bool $includeFrom = true, bool $includeTo = true)
39 39
     {
40
-        if (is_array($expression) || (is_object($expression) && !$expression instanceof ValueInterface)) {
40
+        if (is_array($expression) || (is_object($expression) && !$expression instanceof ValueInterface))
41
+        {
41 42
             throw new ValueException(sprintf(
42 43
                 'Expression expected to be instance of `%s` or a scalar value, got %s.',
43 44
                 ValueInterface::class,
@@ -45,7 +46,8 @@  discard block
 block discarded – undo
45 46
             ));
46 47
         }
47 48
 
48
-        if (!$this->isValidArray($value)) {
49
+        if (!$this->isValidArray($value))
50
+        {
49 51
             throw new ValueException(sprintf(
50 52
                 'Value expected to be an array of 2 different scalar elements, got %s.',
51 53
                 $this->invalidValueType($value)
@@ -66,12 +68,14 @@  discard block
 block discarded – undo
66 68
     public function withValue($value): ?SpecificationInterface
67 69
     {
68 70
         $between = clone $this;
69
-        if (!$between->expression instanceof ValueInterface) {
71
+        if (!$between->expression instanceof ValueInterface)
72
+        {
70 73
             //constant value
71 74
             return $between;
72 75
         }
73 76
 
74
-        if (!$between->expression->accepts($value)) {
77
+        if (!$between->expression->accepts($value))
78
+        {
75 79
             return null;
76 80
         }
77 81
 
@@ -102,7 +106,8 @@  discard block
 block discarded – undo
102 106
      */
103 107
     public function getFilters(bool $asOriginal = false): array
104 108
     {
105
-        if ($asOriginal && $this->includeFrom && $this->includeTo) {
109
+        if ($asOriginal && $this->includeFrom && $this->includeTo)
110
+        {
106 111
             return [$this];
107 112
         }
108 113
 
@@ -116,7 +121,8 @@  discard block
 block discarded – undo
116 121
      */
117 122
     private function isValidArray(array $value): bool
118 123
     {
119
-        if (count($value) !== 2) {
124
+        if (count($value) !== 2)
125
+        {
120 126
             return false;
121 127
         }
122 128
 
@@ -132,16 +138,19 @@  discard block
 block discarded – undo
132 138
     private function invalidValueType(array $value): string
133 139
     {
134 140
         $count = count($value);
135
-        if ($count === 0) {
141
+        if ($count === 0)
142
+        {
136 143
             return 'empty array';
137 144
         }
138 145
 
139
-        if ($count !== 2) {
146
+        if ($count !== 2)
147
+        {
140 148
             return "array of $count elements";
141 149
         }
142 150
 
143 151
         [$from, $to] = array_values($value);
144
-        if (!is_scalar($from) || !is_scalar($to)) {
152
+        if (!is_scalar($from) || !is_scalar($to))
153
+        {
145 154
             return 'array of 2 not scalar elements';
146 155
         }
147 156
 
@@ -154,7 +163,8 @@  discard block
 block discarded – undo
154 163
      */
155 164
     private function invalidExpressionType($value): string
156 165
     {
157
-        if (is_object($value)) {
166
+        if (is_object($value))
167
+        {
158 168
             return get_class($value);
159 169
         }
160 170
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Filter/Select.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,16 +38,16 @@
 block discarded – undo
38 38
         $select = $this->clone($value);
39 39
         $value = (array)$value;
40 40
 
41
-        foreach ($this->filters as $name => $filter) {
41
+        foreach ($this->filters as $name => $filter){
42 42
             $name = (string)$name;
43
-            if (!hasValue($value, $name)) {
43
+            if (!hasValue($value, $name)){
44 44
                 continue;
45 45
             }
46 46
 
47 47
             $select->filters[$name] = $filter;
48 48
         }
49 49
 
50
-        if (empty($select->filters)) {
50
+        if (empty($select->filters)){
51 51
             return null;
52 52
         }
53 53
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -3 removed lines patch added patch discarded remove patch
@@ -38,16 +38,19 @@
 block discarded – undo
38 38
         $select = $this->clone($value);
39 39
         $value = (array)$value;
40 40
 
41
-        foreach ($this->filters as $name => $filter) {
41
+        foreach ($this->filters as $name => $filter)
42
+        {
42 43
             $name = (string)$name;
43
-            if (!hasValue($value, $name)) {
44
+            if (!hasValue($value, $name))
45
+            {
44 46
                 continue;
45 47
             }
46 48
 
47 49
             $select->filters[$name] = $filter;
48 50
         }
49 51
 
50
-        if (empty($select->filters)) {
52
+        if (empty($select->filters))
53
+        {
51 54
             return null;
52 55
         }
53 56
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Filter/All.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
     public function withValue($value): ?SpecificationInterface
32 32
     {
33 33
         $all = $this->clone($value);
34
-        foreach ($this->filters as $filter) {
34
+        foreach ($this->filters as $filter){
35 35
             $applied = $filter->withValue($value);
36 36
 
37
-            if ($applied === null) {
37
+            if ($applied === null){
38 38
                 // all nested filters must be configured
39 39
                 return null;
40 40
             }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,12 @@
 block discarded – undo
31 31
     public function withValue($value): ?SpecificationInterface
32 32
     {
33 33
         $all = $this->clone($value);
34
-        foreach ($this->filters as $filter) {
34
+        foreach ($this->filters as $filter)
35
+        {
35 36
             $applied = $filter->withValue($value);
36 37
 
37
-            if ($applied === null) {
38
+            if ($applied === null)
39
+            {
38 40
                 // all nested filters must be configured
39 41
                 return null;
40 42
             }
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Filter/Expression.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,12 +40,12 @@
 block discarded – undo
40 40
     public function withValue($value): ?SpecificationInterface
41 41
     {
42 42
         $filter = clone $this;
43
-        if (!$filter->value instanceof ValueInterface) {
43
+        if (!$filter->value instanceof ValueInterface){
44 44
             // constant value
45 45
             return $filter;
46 46
         }
47 47
 
48
-        if (!$filter->value->accepts($value)) {
48
+        if (!$filter->value->accepts($value)){
49 49
             // invalid value
50 50
             return null;
51 51
         }
Please login to merge, or discard this patch.
Braces   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -40,12 +40,14 @@
 block discarded – undo
40 40
     public function withValue($value): ?SpecificationInterface
41 41
     {
42 42
         $filter = clone $this;
43
-        if (!$filter->value instanceof ValueInterface) {
43
+        if (!$filter->value instanceof ValueInterface)
44
+        {
44 45
             // constant value
45 46
             return $filter;
46 47
         }
47 48
 
48
-        if (!$filter->value->accepts($value)) {
49
+        if (!$filter->value->accepts($value))
50
+        {
49 51
             // invalid value
50 52
             return null;
51 53
         }
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Filter/Map.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,21 +36,21 @@
 block discarded – undo
36 36
      */
37 37
     public function withValue($value): ?SpecificationInterface
38 38
     {
39
-        if (!is_array($value)) {
39
+        if (!is_array($value)){
40 40
             // only array values are expected
41 41
             return null;
42 42
         }
43 43
 
44 44
         $map = $this->clone($value);
45
-        foreach ($this->filters as $name => $filter) {
45
+        foreach ($this->filters as $name => $filter){
46 46
             $name = (string)$name;
47
-            if (!hasKey($value, $name)) {
47
+            if (!hasKey($value, $name)){
48 48
                 // all values must be provided
49 49
                 return null;
50 50
             }
51 51
 
52 52
             $applied = $filter->withValue($value[$name]);
53
-            if ($applied === null) {
53
+            if ($applied === null){
54 54
                 return null;
55 55
             }
56 56
 
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -36,21 +36,25 @@
 block discarded – undo
36 36
      */
37 37
     public function withValue($value): ?SpecificationInterface
38 38
     {
39
-        if (!is_array($value)) {
39
+        if (!is_array($value))
40
+        {
40 41
             // only array values are expected
41 42
             return null;
42 43
         }
43 44
 
44 45
         $map = $this->clone($value);
45
-        foreach ($this->filters as $name => $filter) {
46
+        foreach ($this->filters as $name => $filter)
47
+        {
46 48
             $name = (string)$name;
47
-            if (!hasKey($value, $name)) {
49
+            if (!hasKey($value, $name))
50
+            {
48 51
                 // all values must be provided
49 52
                 return null;
50 53
             }
51 54
 
52 55
             $applied = $filter->withValue($value[$name]);
53
-            if ($applied === null) {
56
+            if ($applied === null)
57
+            {
54 58
                 return null;
55 59
             }
56 60
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Value/NumericValue.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,7 @@
 block discarded – undo
31 31
      */
32 32
     public function convert($value)
33 33
     {
34
-        if (is_numeric($value)) {
34
+        if (is_numeric($value)){
35 35
             return $value + 0;
36 36
         }
37 37
 
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -31,7 +31,8 @@
 block discarded – undo
31 31
      */
32 32
     public function convert($value)
33 33
     {
34
-        if (is_numeric($value)) {
34
+        if (is_numeric($value))
35
+        {
35 36
             return $value + 0;
36 37
         }
37 38
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Value/RangeValue.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,11 +65,11 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function validateBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void
67 67
     {
68
-        if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)) {
68
+        if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)){
69 69
             throw new ValueException('Range boundaries should be applicable via passed type.');
70 70
         }
71 71
 
72
-        if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)) {
72
+        if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)){
73 73
             throw new ValueException('Range boundaries should be different.');
74 74
         }
75 75
     }
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function acceptsFrom($value): bool
100 100
     {
101
-        if ($this->from->empty) {
101
+        if ($this->from->empty){
102 102
             return true;
103 103
         }
104 104
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     private function acceptsTo($value): bool
115 115
     {
116
-        if ($this->to->empty) {
116
+        if ($this->to->empty){
117 117
             return true;
118 118
         }
119 119
 
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     private function setBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void
130 130
     {
131 131
         //Swap if from < to and both not empty
132
-        if (!$from->empty && !$to->empty && $from->value > $to->value) {
132
+        if (!$from->empty && !$to->empty && $from->value > $to->value){
133 133
             [$from, $to] = [$to, $from];
134 134
         }
135 135
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -5 removed lines patch added patch discarded remove patch
@@ -65,11 +65,13 @@  discard block
 block discarded – undo
65 65
      */
66 66
     private function validateBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void
67 67
     {
68
-        if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to)) {
68
+        if (!$this->acceptsBoundary($from) || !$this->acceptsBoundary($to))
69
+        {
69 70
             throw new ValueException('Range boundaries should be applicable via passed type.');
70 71
         }
71 72
 
72
-        if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to)) {
73
+        if ($this->convertBoundaryValue($from) === $this->convertBoundaryValue($to))
74
+        {
73 75
             throw new ValueException('Range boundaries should be different.');
74 76
         }
75 77
     }
@@ -98,7 +100,8 @@  discard block
 block discarded – undo
98 100
      */
99 101
     private function acceptsFrom($value): bool
100 102
     {
101
-        if ($this->from->empty) {
103
+        if ($this->from->empty)
104
+        {
102 105
             return true;
103 106
         }
104 107
 
@@ -113,7 +116,8 @@  discard block
 block discarded – undo
113 116
      */
114 117
     private function acceptsTo($value): bool
115 118
     {
116
-        if ($this->to->empty) {
119
+        if ($this->to->empty)
120
+        {
117 121
             return true;
118 122
         }
119 123
 
@@ -129,7 +133,8 @@  discard block
 block discarded – undo
129 133
     private function setBoundaries(RangeValue\Boundary $from, RangeValue\Boundary $to): void
130 134
     {
131 135
         //Swap if from < to and both not empty
132
-        if (!$from->empty && !$to->empty && $from->value > $to->value) {
136
+        if (!$from->empty && !$to->empty && $from->value > $to->value)
137
+        {
133 138
             [$from, $to] = [$to, $from];
134 139
         }
135 140
 
Please login to merge, or discard this patch.
src/DataGrid/src/Specification/Value/EnumValue.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __construct(ValueInterface $base, ...$values)
31 31
     {
32
-        if ($base instanceof static) {
32
+        if ($base instanceof static){
33 33
             throw new ValueException(sprintf('Nested value type not allowed, got `%s`', get_class($base)));
34 34
         }
35 35
 
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function accepts($value): bool
44 44
     {
45
-        if (!$this->base->accepts($value)) {
45
+        if (!$this->base->accepts($value)){
46 46
             return false;
47 47
         }
48 48
 
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function convertEnum(array $values): array
65 65
     {
66
-        if (empty($values)) {
66
+        if (empty($values)){
67 67
             throw new ValueException('Enum set should not be empty');
68 68
         }
69 69
 
70 70
         $type = new ArrayValue($this->base);
71
-        if (!$type->accepts($values)) {
71
+        if (!$type->accepts($values)){
72 72
             throw new ValueException(
73 73
                 sprintf(
74 74
                     '"Got non-compatible values, expected only compatible with `%s`.',
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,7 +29,8 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function __construct(ValueInterface $base, ...$values)
31 31
     {
32
-        if ($base instanceof static) {
32
+        if ($base instanceof static)
33
+        {
33 34
             throw new ValueException(sprintf('Nested value type not allowed, got `%s`', get_class($base)));
34 35
         }
35 36
 
@@ -42,7 +43,8 @@  discard block
 block discarded – undo
42 43
      */
43 44
     public function accepts($value): bool
44 45
     {
45
-        if (!$this->base->accepts($value)) {
46
+        if (!$this->base->accepts($value))
47
+        {
46 48
             return false;
47 49
         }
48 50
 
@@ -63,12 +65,14 @@  discard block
 block discarded – undo
63 65
      */
64 66
     private function convertEnum(array $values): array
65 67
     {
66
-        if (empty($values)) {
68
+        if (empty($values))
69
+        {
67 70
             throw new ValueException('Enum set should not be empty');
68 71
         }
69 72
 
70 73
         $type = new ArrayValue($this->base);
71
-        if (!$type->accepts($values)) {
74
+        if (!$type->accepts($values))
75
+        {
72 76
             throw new ValueException(
73 77
                 sprintf(
74 78
                     '"Got non-compatible values, expected only compatible with `%s`.',
Please login to merge, or discard this patch.