| Total Complexity | 8 |
| Total Lines | 53 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 15 | final class TupleStorage implements IteratorAggregate, Countable |
||
| 16 | { |
||
| 17 | /** @var SplObjectStorage<object, Tuple> */ |
||
| 18 | private SplObjectStorage $storage; |
||
| 19 | |||
| 20 | public function __construct() |
||
| 23 | } |
||
| 24 | |||
| 25 | public function getIterator(): \Traversable |
||
| 26 | { |
||
| 27 | $this->storage->rewind(); |
||
| 28 | |||
| 29 | while ($this->storage->valid()) { |
||
| 30 | $entity = $this->storage->current(); |
||
| 31 | $tuple = $this->storage->getInfo(); |
||
| 32 | $this->storage->next(); |
||
| 33 | yield $entity => $tuple; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Returns {@see Tuple} if exists, throws an exception otherwise. |
||
| 39 | * |
||
| 40 | * @throws \Throwable if the entity is not found in the storage |
||
| 41 | */ |
||
| 42 | public function getTuple(object $entity): Tuple |
||
| 45 | } |
||
| 46 | |||
| 47 | public function attach(Tuple $tuple): void |
||
| 50 | } |
||
| 51 | |||
| 52 | public function contains(object $entity): bool |
||
| 55 | } |
||
| 56 | |||
| 57 | public function detach(object $entity): void |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @return int<0, max> |
||
| 64 | */ |
||
| 65 | public function count(): int |
||
| 70 |