| Total Complexity | 11 |
| Total Lines | 99 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Collection implements CollectionInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * An array containing the entries of this collection. |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | protected $elements; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * Initializes a new ArrayCollection. |
||
| 18 | * |
||
| 19 | * @param array $elements |
||
| 20 | */ |
||
| 21 | 55 | public function __construct(array $elements = []) |
|
| 22 | { |
||
| 23 | 55 | $this->elements = $elements; |
|
| 24 | 55 | } |
|
| 25 | |||
| 26 | /** |
||
| 27 | * {@inheritdoc} |
||
| 28 | */ |
||
| 29 | 1 | public function isEmpty(): bool |
|
| 30 | { |
||
| 31 | 1 | return empty($this->elements); |
|
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * {@inheritdoc} |
||
| 36 | */ |
||
| 37 | 21 | public function all(): array |
|
| 38 | { |
||
| 39 | 21 | return $this->elements; |
|
| 40 | } |
||
| 41 | |||
| 42 | /** |
||
| 43 | * {@inheritdoc} |
||
| 44 | */ |
||
| 45 | 10 | public function count() |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * {@inheritdoc} |
||
| 52 | */ |
||
| 53 | 6 | public function first() |
|
| 54 | { |
||
| 55 | 6 | return reset($this->elements); |
|
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * {@inheritdoc} |
||
| 60 | */ |
||
| 61 | 4 | public function last() |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | */ |
||
| 69 | 6 | public function key() |
|
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * {@inheritdoc} |
||
| 76 | */ |
||
| 77 | 9 | public function next() |
|
| 78 | { |
||
| 79 | 9 | return next($this->elements); |
|
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
| 83 | * {@inheritdoc} |
||
| 84 | */ |
||
| 85 | 6 | public function current() |
|
| 86 | { |
||
| 87 | 6 | return current($this->elements); |
|
| 88 | } |
||
| 89 | |||
| 90 | /** |
||
| 91 | * {@inheritdoc} |
||
| 92 | */ |
||
| 93 | 3 | public function getIterator() |
|
| 96 | } |
||
| 97 | |||
| 98 | /** |
||
| 99 | * Returns a string representation of this object. |
||
| 100 | * |
||
| 101 | * @return string |
||
| 102 | */ |
||
| 103 | 1 | public function __toString() |
|
| 108 |