Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| PdfVersion | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
5 | |
100.00% |
1 / 1 |
| isAtLeast | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isGreaterThan | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| max | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| fromString | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Phpdftk\Pdf\Core; |
| 6 | |
| 7 | /** |
| 8 | * PDF specification versions — ISO 32000-1 (1.x) and ISO 32000-2 (2.0). |
| 9 | * |
| 10 | * Used to declare minimum version requirements for PDF features and to |
| 11 | * control the version written to the %PDF-X.Y file header. |
| 12 | */ |
| 13 | enum PdfVersion: string |
| 14 | { |
| 15 | case V1_0 = '1.0'; |
| 16 | case V1_1 = '1.1'; |
| 17 | case V1_2 = '1.2'; |
| 18 | /** Introduced digital signatures and interactive forms. */ |
| 19 | case V1_3 = '1.3'; |
| 20 | /** Introduced transparency, JBIG2, and encryption revision 3. */ |
| 21 | case V1_4 = '1.4'; |
| 22 | /** Introduced cross-reference streams and object streams. */ |
| 23 | case V1_5 = '1.5'; |
| 24 | /** Introduced AES-128 encryption and OpenType font embedding. */ |
| 25 | case V1_6 = '1.6'; |
| 26 | /** Final Acrobat-era version — the default for most new PDFs. */ |
| 27 | case V1_7 = '1.7'; |
| 28 | /** ISO 32000-2 — AES-256, tagged PDF improvements, deprecations. */ |
| 29 | case V2_0 = '2.0'; |
| 30 | |
| 31 | public function isAtLeast(self $other): bool |
| 32 | { |
| 33 | return version_compare($this->value, $other->value, '>='); |
| 34 | } |
| 35 | |
| 36 | public function isGreaterThan(self $other): bool |
| 37 | { |
| 38 | return version_compare($this->value, $other->value, '>'); |
| 39 | } |
| 40 | |
| 41 | /** Return the higher of two versions. */ |
| 42 | public function max(self $other): self |
| 43 | { |
| 44 | return $this->isAtLeast($other) ? $this : $other; |
| 45 | } |
| 46 | |
| 47 | /** Parse a version string like '1.7' into an enum case, or null. */ |
| 48 | public static function fromString(string $version): ?self |
| 49 | { |
| 50 | return self::tryFrom($version); |
| 51 | } |
| 52 | } |