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
GeneratedCodeStatus 100.00% 4 / 4 100.00% 4 / 4 6 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 hasCurrentFormat 100.00% 1 / 1 100.00% 1 / 1 1
 hasDrift 100.00% 1 / 1 100.00% 1 / 1 2
 hasSameDriftAs 100.00% 1 / 1 100.00% 1 / 1 2
1<?php
2
3declare(strict_types=1);
4
5namespace Stewart\Runtime\Control\Protocol\Status;
6
7use Stewart\Contracts\Time\Instant;
8use Stewart\Contracts\Wire\ListOf;
9
10final readonly class GeneratedCodeStatus
11{
12    /**
13     * @param list<string> $added
14     * @param list<string> $removed
15     */
16    public function __construct(
17        public int $format,
18        public int $expectedFormat,
19        #[ListOf('string')]
20        public array $added,
21        #[ListOf('string')]
22        public array $removed,
23        public Instant $checkedAt,
24    ) {}
25
26    public function hasCurrentFormat(): bool
27    {
28        return $this->format === $this->expectedFormat;
29    }
30
31    public function hasDrift(): bool
32    {
33        return $this->added !== [] || $this->removed !== [];
34    }
35
36    public function hasSameDriftAs(self $other): bool
37    {
38        return $this->added === $other->added && $this->removed === $other->removed;
39    }
40}