Lines 0.00% 0 / 14
Functions and Methods 0.00% 0 / 2
Classes and Traits 0.00% 0 / 1
Name Lines Functions and Methods CRAP Classes and Traits
GenerationReport 0.00% 0 / 14 0.00% 0 / 2 6 0.00% 0 / 1
 __construct 0.00% 0 / 1 0.00% 0 / 1 2
 summary 0.00% 0 / 13 0.00% 0 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Codegen\Output;
6
7use Stewart\Codegen\Model\GenerationWarning;
8use Stewart\Codegen\Output\Collection\FileChangeCollection;
9
10final readonly class GenerationReport
11{
12    /** @param list<GenerationWarning> $warnings */
13    public function __construct(
14        public FileChangeCollection $changes,
15        public int $entities,
16        public int $domains,
17        public int $services,
18        public int $ignored,
19        public int $attributes,
20        public array $warnings,
21        public string $haVersion,
22    ) {}
23
24    public function summary(): string
25    {
26        return \sprintf(
27            'entities: %d in %d domains · attributes: %d typed · services: %d · files created/updated/unchanged/deleted: %d/%d/%d/%d · ignored: %d · from Home Assistant %s',
28            $this->entities,
29            $this->domains,
30            $this->attributes,
31            $this->services,
32            $this->changes->countWithOutcome(FileOutcome::Created),
33            $this->changes->countWithOutcome(FileOutcome::Updated),
34            $this->changes->countWithOutcome(FileOutcome::Unchanged),
35            $this->changes->countWithOutcome(FileOutcome::Deleted),
36            $this->ignored,
37            $this->haVersion,
38        );
39    }
40}