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
ServiceCatalog 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\Service;
6
7use Stewart\Codegen\Service\Collection\ServiceDefinitionCollection;
8
9final readonly class ServiceCatalog
10{
11    /** @param array<string, ServiceDefinitionCollection> $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): ServiceDefinitionCollection
21    {
22        return $this->byDomain[$domain] ?? ServiceDefinitionCollection::empty();
23    }
24
25    public function forEntityHandle(string $domain): ServiceDefinitionCollection
26    {
27        return $this->forDomain($domain)->forEntityHandle($domain);
28    }
29}