Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
StatusReport
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
6
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 clean
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
5
1<?php
2
3declare(strict_types=1);
4
5namespace Celemas\Verba\Tool;
6
7/**
8 * The outcome of a status check: per-locale gaps and any scanner warnings.
9 *
10 * @api
11 */
12final class StatusReport
13{
14    /**
15     * @param array<string, array{
16     *     missing: int,
17     *     untranslated: int,
18     *     translated: int,
19     *     obsolete: int,
20     *     total: int,
21     *     locations: list<string>,
22     * }> $locales
23     * @param list<string> $warnings
24     */
25    public function __construct(
26        public readonly string $domain,
27        public readonly array $locales,
28        public readonly array $warnings,
29    ) {}
30
31    /**
32     * True when every locale is fully translated with nothing missing or stale.
33     */
34    public function clean(): bool
35    {
36        foreach ($this->locales as $stat) {
37            if ($stat['missing'] > 0 || $stat['untranslated'] > 0 || $stat['obsolete'] > 0) {
38                return false;
39            }
40        }
41
42        return true;
43    }
44}