Total Complexity | 11 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Coverage | 94.12% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait InteractsWithIdentifier |
||
10 | { |
||
11 | private readonly SimpleXMLElement $opfXml; |
||
12 | private readonly string $dcNamespace; |
||
13 | |||
14 | /** |
||
15 | * Gets the authors of the EPUB. |
||
16 | * |
||
17 | * @return array<int, string> |
||
18 | */ |
||
19 | 9 | public function getIdentifiers(): array |
|
20 | { |
||
21 | 9 | $this->opfXml->registerXPathNamespace('dc', $this->dcNamespace); |
|
22 | |||
23 | 9 | $identifierNodes = $this->opfXml->xpath('//dc:identifier'); |
|
24 | |||
25 | 9 | $identifiers = []; |
|
26 | |||
27 | 9 | if ($identifierNodes === false || $identifierNodes === null || $identifierNodes === []) { |
|
28 | return $identifiers; |
||
29 | } |
||
30 | |||
31 | 9 | foreach ($identifierNodes as $identifierNode) { |
|
32 | 9 | $identifiers[] = (string) $identifierNode; |
|
33 | } |
||
34 | 9 | return $identifiers; |
|
35 | } |
||
36 | |||
37 | /** |
||
38 | * Sets the identifiers of the EPUB. |
||
39 | * |
||
40 | * @param array<int, string> $identifiers |
||
41 | */ |
||
42 | 1 | public function setIdentifiers(array $identifiers): void |
|
56 | } |
||
57 | } |
||
59 |