|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace TinyBlocks\Mapper\Models; |
| 6 | + |
| 7 | +use Closure; |
| 8 | +use TinyBlocks\Collection\Collectible; |
| 9 | +use TinyBlocks\Collection\PreserveKeys; |
| 10 | +use TinyBlocks\Mapper\IterableMappability; |
| 11 | +use TinyBlocks\Mapper\IterableMapper; |
| 12 | +use Traversable; |
| 13 | + |
| 14 | +final readonly class Collection implements Collectible |
| 15 | +{ |
| 16 | + //use IterableMappability; |
| 17 | + |
| 18 | + private iterable $iterator; |
| 19 | + |
| 20 | + private function __construct(iterable $iterator) |
| 21 | + { |
| 22 | + $this->iterator = $iterator; |
| 23 | + } |
| 24 | + |
| 25 | + public static function createFrom(iterable $elements): Collectible |
| 26 | + { |
| 27 | + return new Collection(iterator: $elements); |
| 28 | + } |
| 29 | + |
| 30 | + public static function createFromEmpty(): Collectible |
| 31 | + { |
| 32 | + // TODO: Implement createFromEmpty() method. |
| 33 | + } |
| 34 | + |
| 35 | + public function add(...$elements): Collectible |
| 36 | + { |
| 37 | + // TODO: Implement add() method. |
| 38 | + } |
| 39 | + |
| 40 | + public function contains(mixed $element): bool |
| 41 | + { |
| 42 | + // TODO: Implement contains() method. |
| 43 | + } |
| 44 | + |
| 45 | + public function count(): int |
| 46 | + { |
| 47 | + return iterator_count($this->iterator); |
| 48 | + } |
| 49 | + |
| 50 | + public function each(Closure ...$actions): Collectible |
| 51 | + { |
| 52 | + // TODO: Implement each() method. |
| 53 | + } |
| 54 | + |
| 55 | + public function equals(Collectible $other): bool |
| 56 | + { |
| 57 | + // TODO: Implement equals() method. |
| 58 | + } |
| 59 | + |
| 60 | + public function filter(?Closure ...$predicates): Collectible |
| 61 | + { |
| 62 | + // TODO: Implement filter() method. |
| 63 | + } |
| 64 | + |
| 65 | + public function findBy(Closure ...$predicates): mixed |
| 66 | + { |
| 67 | + // TODO: Implement findBy() method. |
| 68 | + } |
| 69 | + |
| 70 | + public function first(mixed $defaultValueIfNotFound = null): mixed |
| 71 | + { |
| 72 | + // TODO: Implement first() method. |
| 73 | + } |
| 74 | + |
| 75 | + public function flatten(): Collectible |
| 76 | + { |
| 77 | + // TODO: Implement flatten() method. |
| 78 | + } |
| 79 | + |
| 80 | + public function getBy(int $index, mixed $defaultValueIfNotFound = null): mixed |
| 81 | + { |
| 82 | + // TODO: Implement getBy() method. |
| 83 | + } |
| 84 | + |
| 85 | + public function getIterator(): Traversable |
| 86 | + { |
| 87 | + yield from $this->iterator; |
| 88 | + } |
| 89 | + |
| 90 | + public function groupBy(Closure $grouping): Collectible |
| 91 | + { |
| 92 | + // TODO: Implement groupBy() method. |
| 93 | + } |
| 94 | + |
| 95 | + public function isEmpty(): bool |
| 96 | + { |
| 97 | + // TODO: Implement isEmpty() method. |
| 98 | + } |
| 99 | + |
| 100 | + public function joinToString(string $separator): string |
| 101 | + { |
| 102 | + // TODO: Implement joinToString() method. |
| 103 | + } |
| 104 | + |
| 105 | + public function last(mixed $defaultValueIfNotFound = null): mixed |
| 106 | + { |
| 107 | + // TODO: Implement last() method. |
| 108 | + } |
| 109 | + |
| 110 | + public function map(Closure ...$transformations): Collectible |
| 111 | + { |
| 112 | + // TODO: Implement map() method. |
| 113 | + } |
| 114 | + |
| 115 | + public function remove(mixed $element): Collectible |
| 116 | + { |
| 117 | + // TODO: Implement remove() method. |
| 118 | + } |
| 119 | + |
| 120 | + public function removeAll(?Closure $filter = null): Collectible |
| 121 | + { |
| 122 | + // TODO: Implement removeAll() method. |
| 123 | + } |
| 124 | + |
| 125 | + public function reduce(Closure $aggregator, mixed $initial): mixed |
| 126 | + { |
| 127 | + // TODO: Implement reduce() method. |
| 128 | + } |
| 129 | + |
| 130 | + public function sort( |
| 131 | + \TinyBlocks\Collection\Order $order = \TinyBlocks\Collection\Order::ASCENDING_KEY, |
| 132 | + ?Closure $predicate = null |
| 133 | + ): Collectible { |
| 134 | + // TODO: Implement sort() method. |
| 135 | + } |
| 136 | + |
| 137 | + public function slice(int $index, int $length = -1): Collectible |
| 138 | + { |
| 139 | + // TODO: Implement slice() method. |
| 140 | + } |
| 141 | + |
| 142 | + public function toArray(PreserveKeys $preserveKeys = PreserveKeys::PRESERVE): array |
| 143 | + { |
| 144 | + // TODO: Implement toArray() method. |
| 145 | + } |
| 146 | + |
| 147 | + public function toJson(PreserveKeys $preserveKeys = PreserveKeys::PRESERVE): string |
| 148 | + { |
| 149 | + // TODO: Implement toJson() method. |
| 150 | + } |
| 151 | +} |
0 commit comments