Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
OutputIntentConstraint
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
3
100.00% covered (success)
100.00%
1 / 1
 check
100.00% covered (success)
100.00%
15 / 15
100.00% covered (success)
100.00%
1 / 1
3
1<?php
2
3declare(strict_types=1);
4
5namespace Phpdftk\Pdf\Conformance\Constraint;
6
7use Phpdftk\Pdf\Conformance\Inspection\DocumentInspector;
8use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile;
9use Phpdftk\Pdf\Conformance\Profile\PdfAProfile;
10use Phpdftk\Pdf\Conformance\Result\ConformanceViolation;
11use Phpdftk\Pdf\Conformance\Result\ViolationSeverity;
12
13/**
14 * PDF/A clause 6.2.2: At least one OutputIntent with the correct
15 * subtype and an embedded ICC profile is required.
16 */
17final class OutputIntentConstraint implements ConformanceConstraint
18{
19    public function check(DocumentInspector $inspector, ConformanceProfile $profile): array
20    {
21        $violations = [];
22
23        if (!$inspector->hasOutputIntents()) {
24            $violations[] = new ConformanceViolation(
25                clause: '6.2.2',
26                message: 'At least one OutputIntent is required for ' . $profile->getFamily() . '-' . $profile->getLevel(),
27                severity: ViolationSeverity::Error,
28            );
29            return $violations;
30        }
31
32        if (!$inspector->hasOutputIntentWithIccProfile()) {
33            $violations[] = new ConformanceViolation(
34                clause: '6.2.2',
35                message: 'OutputIntent must include a /DestOutputProfile (embedded ICC profile)',
36                severity: ViolationSeverity::Error,
37            );
38        }
39
40        return $violations;
41    }
42}