Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
ConformanceResult
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
3 / 3
3
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
 getErrors
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getWarnings
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Conformance\Result;
6
7use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile;
8
9/**
10 * The result of validating a document against a conformance profile.
11 */
12final readonly class ConformanceResult
13{
14    /**
15     * @param list<ConformanceViolation> $violations
16     */
17    public function __construct(
18        public ConformanceProfile $profile,
19        public bool $isCompliant,
20        public array $violations,
21    ) {}
22
23    /** @return list<ConformanceViolation> */
24    public function getErrors(): array
25    {
26        return array_values(array_filter(
27            $this->violations,
28            static fn(ConformanceViolation $v) => $v->severity === ViolationSeverity::Error,
29        ));
30    }
31
32    /** @return list<ConformanceViolation> */
33    public function getWarnings(): array
34    {
35        return array_values(array_filter(
36            $this->violations,
37            static fn(ConformanceViolation $v) => $v->severity === ViolationSeverity::Warning,
38        ));
39    }
40}