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 Celema\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     *     parked: list<string>,
23     *     vanished: list<string>,
24     * }> $locales
25     * @param list<string> $warnings
26     */
27    public function __construct(
28        public readonly string $domain,
29        public readonly array $locales,
30        public readonly array $warnings,
31    ) {}
32
33    /**
34     * True when every locale is fully translated with nothing missing or stale.
35     */
36    public function clean(): bool
37    {
38        foreach ($this->locales as $stat) {
39            if ($stat['missing'] > 0 || $stat['untranslated'] > 0 || $stat['obsolete'] > 0) {
40                return false;
41            }
42        }
43
44        return true;
45    }
46}