File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ protected function fillCustom(array $groups): array
4040 protected function fillDefault (array $ groups ): array
4141 {
4242 foreach ($ this ->groups () as $ group ) {
43- if (! in_array ($ group , $ groups )) {
43+ if (! in_array ($ group , $ groups, true )) {
4444 $ groups [] = $ group ;
4545 }
4646 }
@@ -54,7 +54,7 @@ protected function existGroup(int $value): bool
5454 }
5555
5656 /**
57- * @return array< Group>
57+ * @return Group[]
5858 */
5959 protected function groups (): array
6060 {
Original file line number Diff line number Diff line change 77use DragonCode \SizeSorter \Enum \Group ;
88use DragonCode \SizeSorter \Services \MainLogic ;
99use DragonCode \SizeSorter \Services \Order ;
10- use Illuminate \ Support \Collection ;
10+ use DragonCode \ SizeSorter \ Support \Validator ;
1111
1212class SizeSorter
1313{
@@ -22,7 +22,7 @@ public static function items(iterable $items): static
2222
2323 public function __construct (
2424 protected readonly iterable $ items ,
25- protected readonly Order $ order = new Order
25+ protected readonly Order $ order = new Order ()
2626 ) {}
2727
2828 public function column (string $ name ): static
@@ -34,11 +34,12 @@ public function column(string $name): static
3434
3535 /**
3636 * @param Group[]|null $order
37+ *
3738 * @return $this
3839 */
3940 public function orderBy (?array $ order ): static
4041 {
41- ( new Collection ( $ order))-> ensure ( Group::class);
42+ Validator:: ensure ( $ order, Group::class);
4243
4344 $ this ->orderBy = $ this ->order ->resolve ($ order );
4445
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace DragonCode \SizeSorter \Support ;
6+
7+ use Illuminate \Support \Collection ;
8+
9+ class Validator
10+ {
11+ public static function ensure (?iterable $ items , string $ class ): void
12+ {
13+ (new Collection ($ items ))->ensure ($ class );
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments