Lines 100.00% 2 / 2
Functions and Methods 100.00% 2 / 2
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
FloorCollection 100.00% 2 / 2 100.00% 2 / 2 2 100.00% 1 / 1
 keyedByFloorId 100.00% 1 / 1 100.00% 1 / 1 1
 find 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Contracts\Registry\Collection;
6
7use Stewart\Contracts\Collection\KeyedCollection;
8use Stewart\Contracts\Registry\Floor;
9use Stewart\Contracts\Registry\FloorId;
10
11/** @extends KeyedCollection<string, Floor> */
12final readonly class FloorCollection extends KeyedCollection
13{
14    /** @param iterable<Floor> $entries */
15    public static function keyedByFloorId(iterable $entries): self
16    {
17        return self::keyedBy($entries, static fn(Floor $entry): string => $entry->floorId->value);
18    }
19
20    public function find(FloorId $floorId): ?Floor
21    {
22        return $this->elementAt($floorId->value);
23    }
24}