@@ -102,7 +102,7 @@ public function withValidator($validator)
102
102
103
103
if ($ this ->input ('shape_id ' ) !== Shape::wholeFrameId ()) {
104
104
105
- $ containsNonArray = collect ($ this ->input ('points ' ))->filter (fn ($ p ) => gettype ($ p ) !== 'array ' )->isNotEmpty ();
105
+ $ containsNonArray = collect ($ this ->input ('points ' ))->filter (fn ($ p ) => gettype ($ p ) !== 'array ' )->isNotEmpty ();
106
106
if ($ containsNonArray ) {
107
107
$ validator ->errors ()->add ('points ' , 'Invalid shape. Either has no points or points in wrong format. ' );
108
108
return ;
@@ -113,35 +113,36 @@ public function withValidator($validator)
113
113
$ exactValue = true ;
114
114
115
115
switch ($ this ->input ('shape_id ' )) {
116
- case (Shape::circleId ()):
116
+ case (Shape::circleId ()):
117
117
$ shapes = collect ($ this ->input ('points ' ));
118
- if ($ shapes ->filter (fn ($ xyr ) => count ($ xyr ) !== 3 )->isNotEmpty () || $ shapes ->filter (fn ($ xyr ) => $ xyr [2 ] === 0 )->isNotEmpty ()) {
118
+ if ($ shapes ->filter (fn ($ xyr ) => count ($ xyr ) !== 3 )->isNotEmpty () || $ shapes ->filter (fn ($ xyr ) => $ xyr [2 ] === 0 )->isNotEmpty ()) {
119
119
$ validator ->errors ()->add ('points ' , 'Invalid shape. ' );
120
120
}
121
121
return ;
122
- case (Shape::ellipseId ()):
123
- case (Shape::rectangleId ()):
122
+ case (Shape::ellipseId ()):
123
+ case (Shape::rectangleId ()):
124
124
$ expectedElementCount = 8 ;
125
125
$ exactValue = true ;
126
126
break ;
127
- case (Shape::lineId ()):
127
+ case (Shape::lineId ()):
128
128
$ expectedElementCount = 4 ;
129
129
$ exactValue = false ;
130
130
break ;
131
- case (Shape::polygonId ()):
131
+ case (Shape::polygonId ()):
132
132
$ expectedElementCount = 6 ;
133
133
$ exactValue = false ;
134
134
break ;
135
135
case (Shape::pointId ()):
136
136
$ expectedElementCount = 2 ;
137
137
$ exactValue = true ;
138
-
138
+
139
139
}
140
140
if ($ this ->hasInvalidShapes ($ shapes , $ expectedElementCount , $ exactValue )) {
141
141
$ validator ->errors ()->add ('points ' , 'Invalid shape. ' );
142
142
}
143
143
}
144
144
145
+
145
146
});
146
147
}
147
148
@@ -181,11 +182,11 @@ protected function annotationContained()
181
182
182
183
/**
183
184
* Checks if shapes have invalid number of (distinct) points
184
- *
185
+ *
185
186
* @param array $pointArrays containing coordinates of (multiple) shapes
186
187
* @param int $expectedCount number of expected x and y coordinates
187
188
* @param bool $exact is used in check for exact or minimum count
188
- *
189
+ *
189
190
* @return bool false is shape is valid, otherwise true
190
191
* **/
191
192
private function hasInvalidShapes ($ pointArrays , $ expectedCount , $ exact )
@@ -196,9 +197,9 @@ private function hasInvalidShapes($pointArrays, $expectedCount, $exact)
196
197
return true ;
197
198
}
198
199
199
- $ x = $ pointCollection ->filter (fn ($ x , $ idx ) => $ idx % 2 === 0 )->values ();
200
- $ y = $ pointCollection ->filter (fn ($ x , $ idx ) => $ idx % 2 === 1 )->values ();
201
- $ coords = collect ($ x ->map (fn ($ x , $ idx ) => [$ x , $ y [$ idx ]]))->unique ();
200
+ $ x = $ pointCollection ->filter (fn ($ x , $ idx ) => $ idx % 2 === 0 )->values ();
201
+ $ y = $ pointCollection ->filter (fn ($ x , $ idx ) => $ idx % 2 === 1 )->values ();
202
+ $ coords = collect ($ x ->map (fn ($ x , $ idx ) => [$ x , $ y [$ idx ]]))->unique ();
202
203
203
204
if ($ exact && (count ($ coords ) !== $ expectedCount / 2 ) || !$ exact && ((count ($ coords ) < $ expectedCount / 2 ))) {
204
205
return true ;
0 commit comments