Lines 100.00% 5 / 5
Functions and Methods 100.00% 5 / 5
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
EntitiesRootEmitter 100.00% 5 / 5 100.00% 5 / 5 5 100.00% 1 / 1
 getClassName 100.00% 1 / 1 100.00% 1 / 1 1
 getClassComment 100.00% 1 / 1 100.00% 1 / 1 1
 listDomains 100.00% 1 / 1 100.00% 1 / 1 1
 getDomainClassName 100.00% 1 / 1 100.00% 1 / 1 1
 buildPropertyComment 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Codegen\Emitter;
6
7use Stewart\Codegen\Model\Collection\DomainModelCollection;
8use Stewart\Codegen\Model\DomainModel;
9use Stewart\Codegen\Model\GenerationModel;
10
11final readonly class EntitiesRootEmitter extends RootEmitter
12{
13    protected function getClassName(): string
14    {
15        return 'Entities';
16    }
17
18    protected function getClassComment(): string
19    {
20        return 'Every entity Home Assistant knows, by domain.';
21    }
22
23    protected function listDomains(GenerationModel $model): DomainModelCollection
24    {
25        return $model->listEntityDomains();
26    }
27
28    protected function getDomainClassName(DomainModel $domain): string
29    {
30        return $domain->getEntitiesClass();
31    }
32
33    protected function buildPropertyComment(string $domain): string
34    {
35        return \sprintf('Entities in the `%s` domain.', $domain);
36    }
37}