Lines 100.00% 4 / 4
Functions and Methods 100.00% 4 / 4
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
ActionCatalog 100.00% 4 / 4 100.00% 4 / 4 4 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 listDomains 100.00% 1 / 1 100.00% 1 / 1 1
 forDomain 100.00% 1 / 1 100.00% 1 / 1 1
 forEntityHandle 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Codegen\Action;
6
7use Stewart\Codegen\Action\Collection\ActionDefinitionCollection;
8
9final readonly class ActionCatalog
10{
11    /** @param array<string, ActionDefinitionCollection> $byDomain */
12    public function __construct(private array $byDomain) {}
13
14    /** @return list<string> */
15    public function listDomains(): array
16    {
17        return array_keys($this->byDomain);
18    }
19
20    public function forDomain(string $domain): ActionDefinitionCollection
21    {
22        return $this->byDomain[$domain] ?? ActionDefinitionCollection::empty();
23    }
24
25    public function forEntityHandle(string $domain): ActionDefinitionCollection
26    {
27        return $this->forDomain($domain)->forEntityHandle($domain);
28    }
29}