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