Total Complexity | 5 |
Total Lines | 43 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
21 | class BoxList implements IteratorAggregate |
||
22 | { |
||
23 | /** |
||
24 | * @var Box[] |
||
25 | */ |
||
26 | private array $list = []; |
||
27 | |||
28 | private bool $isSorted = false; |
||
29 | 58 | ||
30 | public function __construct(private readonly BoxSorter $sorter = new DefaultBoxSorter()) |
||
31 | 58 | { |
|
32 | } |
||
33 | |||
34 | /** |
||
35 | * Do a bulk create. |
||
36 | * |
||
37 | * @param Box[] $boxes |
||
38 | 2 | */ |
|
39 | public static function fromArray(array $boxes, bool $preSorted = false): self |
||
40 | 2 | { |
|
41 | 2 | $list = new self(); |
|
42 | 2 | $list->list = $boxes; |
|
43 | $list->isSorted = $preSorted; |
||
44 | 2 | ||
45 | return $list; |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * @return Traversable<Box> |
||
50 | 57 | */ |
|
51 | public function getIterator(): Traversable |
||
59 | } |
||
60 | 54 | ||
61 | public function insert(Box $item): void |
||
64 | } |
||
65 | } |
||
66 |