| Total Complexity | 5 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 9 | class Metadata |
||
| 10 | { |
||
| 11 | use Traits\InteractsWithTitle; |
||
| 12 | use Traits\InteractsWithDescription; |
||
| 13 | use Traits\InteractsWithDate; |
||
| 14 | use Traits\InteractsWithAuthors; |
||
| 15 | use Traits\InteractsWithPublisher; |
||
| 16 | use Traits\InteractsWithLanguage; |
||
| 17 | use Traits\InteractsWithSubject; |
||
| 18 | use Traits\InteractsWithIdentifier; |
||
| 19 | |||
| 20 | private readonly string $dcNamespace; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Metadata constructor. |
||
| 24 | */ |
||
| 25 | 40 | public function __construct(private readonly SimpleXMLElement $opfXml, private string $opfFilePath) |
|
| 26 | { |
||
| 27 | 40 | $namespaces = $this->opfXml->getNamespaces(true); |
|
| 28 | |||
| 29 | 40 | if (! isset($namespaces['dc'])) { |
|
| 30 | 1 | throw new Exception('Failed to identify dc namespace'); |
|
| 31 | } |
||
| 32 | |||
| 33 | 39 | $this->dcNamespace = $namespaces['dc']; |
|
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Saves the updated OPF file. |
||
| 38 | * |
||
| 39 | * @throws Exception If the OPF file cannot be saved. |
||
| 40 | */ |
||
| 41 | 9 | public function save(): void |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 1 | public function getOpfFilePath(): string |
|
| 55 |