Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| TransparencyConstraint | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
6.03 | |
0.00% |
0 / 1 |
| check | |
90.91% |
10 / 11 |
|
0.00% |
0 / 1 |
6.03 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Conformance\Constraint; |
| 6 | |
| 7 | use Phpdftk\Pdf\Conformance\Inspection\DocumentInspector; |
| 8 | use Phpdftk\Pdf\Conformance\Profile\ConformanceProfile; |
| 9 | use Phpdftk\Pdf\Conformance\Profile\PdfAProfile; |
| 10 | use Phpdftk\Pdf\Conformance\Profile\PdfXProfile; |
| 11 | use Phpdftk\Pdf\Conformance\Result\ConformanceViolation; |
| 12 | use Phpdftk\Pdf\Conformance\Result\ViolationSeverity; |
| 13 | |
| 14 | /** |
| 15 | * Transparency prohibition for PDF/A-1 (clause 6.4) and PDF/X-1a/X-3. |
| 16 | * |
| 17 | * Only applies to profiles that prohibit transparency. |
| 18 | */ |
| 19 | final class TransparencyConstraint implements ConformanceConstraint |
| 20 | { |
| 21 | public function check(DocumentInspector $inspector, ConformanceProfile $profile): array |
| 22 | { |
| 23 | // Check if this profile prohibits transparency |
| 24 | if ($profile instanceof PdfAProfile && !$profile->prohibitsTransparency()) { |
| 25 | return []; |
| 26 | } |
| 27 | if ($profile instanceof PdfXProfile && !$profile->prohibitsTransparency()) { |
| 28 | return []; |
| 29 | } |
| 30 | |
| 31 | if ($inspector->hasTransparency()) { |
| 32 | return [new ConformanceViolation( |
| 33 | clause: '6.4', |
| 34 | message: 'Transparency (page groups with /S /Transparency) is prohibited in ' . $profile->getFamily() . '-' . $profile->getLevel(), |
| 35 | severity: ViolationSeverity::Error, |
| 36 | )]; |
| 37 | } |
| 38 | |
| 39 | return []; |
| 40 | } |
| 41 | } |