@@ -102,7 +102,7 @@ public function withValidator($validator)
102102
103103 if ($ this ->input ('shape_id ' ) !== Shape::wholeFrameId ()) {
104104
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 ();
106106 if ($ containsNonArray ) {
107107 $ validator ->errors ()->add ('points ' , 'Invalid shape. Either has no points or points in wrong format. ' );
108108 return ;
@@ -113,35 +113,36 @@ public function withValidator($validator)
113113 $ exactValue = true ;
114114
115115 switch ($ this ->input ('shape_id ' )) {
116- case (Shape::circleId ()):
116+ case (Shape::circleId ()):
117117 $ 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 ()) {
119119 $ validator ->errors ()->add ('points ' , 'Invalid shape. ' );
120120 }
121121 return ;
122- case (Shape::ellipseId ()):
123- case (Shape::rectangleId ()):
122+ case (Shape::ellipseId ()):
123+ case (Shape::rectangleId ()):
124124 $ expectedElementCount = 8 ;
125125 $ exactValue = true ;
126126 break ;
127- case (Shape::lineId ()):
127+ case (Shape::lineId ()):
128128 $ expectedElementCount = 4 ;
129129 $ exactValue = false ;
130130 break ;
131- case (Shape::polygonId ()):
131+ case (Shape::polygonId ()):
132132 $ expectedElementCount = 6 ;
133133 $ exactValue = false ;
134134 break ;
135135 case (Shape::pointId ()):
136136 $ expectedElementCount = 2 ;
137137 $ exactValue = true ;
138-
138+
139139 }
140140 if ($ this ->hasInvalidShapes ($ shapes , $ expectedElementCount , $ exactValue )) {
141141 $ validator ->errors ()->add ('points ' , 'Invalid shape. ' );
142142 }
143143 }
144144
145+
145146 });
146147 }
147148
@@ -181,11 +182,11 @@ protected function annotationContained()
181182
182183 /**
183184 * Checks if shapes have invalid number of (distinct) points
184- *
185+ *
185186 * @param array $pointArrays containing coordinates of (multiple) shapes
186187 * @param int $expectedCount number of expected x and y coordinates
187188 * @param bool $exact is used in check for exact or minimum count
188- *
189+ *
189190 * @return bool false is shape is valid, otherwise true
190191 * **/
191192 private function hasInvalidShapes ($ pointArrays , $ expectedCount , $ exact )
@@ -196,9 +197,9 @@ private function hasInvalidShapes($pointArrays, $expectedCount, $exact)
196197 return true ;
197198 }
198199
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 ();
202203
203204 if ($ exact && (count ($ coords ) !== $ expectedCount / 2 ) || !$ exact && ((count ($ coords ) < $ expectedCount / 2 ))) {
204205 return true ;
0 commit comments