Lines 0.00% 0 / 2
Functions and Methods 0.00% 0 / 2
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
AppDefinitionCollection 0.00% 0 / 2 0.00% 0 / 2 6 0.00% 0 / 1
 keyedByAppId 0.00% 0 / 1 0.00% 0 / 1 2
 find 0.00% 0 / 1 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\App\Collection;
6
7use Stewart\Contracts\App\AppId;
8use Stewart\Contracts\Collection\KeyedCollection;
9use Stewart\Runtime\App\AppDefinition;
10
11/** @extends KeyedCollection<string, AppDefinition> */
12final readonly class AppDefinitionCollection extends KeyedCollection
13{
14    /** @param iterable<AppDefinition> $definitions */
15    public static function keyedByAppId(iterable $definitions): self
16    {
17        return self::keyedBy($definitions, static fn(AppDefinition $definition): string => $definition->id->value);
18    }
19
20    public function find(AppId $id): ?AppDefinition
21    {
22        return $this->elementAt($id->value);
23    }
24}