Total Complexity | 9 |
Total Lines | 35 |
Duplicated Lines | 0 % |
Coverage | 83.33% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait InteractsWithLanguage |
||
10 | { |
||
11 | private readonly SimpleXMLElement $opfXml; |
||
12 | private readonly string $dcNamespace; |
||
13 | |||
14 | /** |
||
15 | * Gets the language of the EPUB. |
||
16 | */ |
||
17 | 9 | public function getLanguage(): string |
|
18 | { |
||
19 | 9 | $this->opfXml->registerXPathNamespace('dc', $this->dcNamespace); |
|
20 | |||
21 | 9 | $languageNode = $this->opfXml->xpath('//dc:language'); |
|
22 | |||
23 | 9 | if ($languageNode === false || $languageNode === null || $languageNode === []) { |
|
24 | return ''; |
||
25 | } |
||
26 | |||
27 | 9 | return (string) $languageNode[0]; |
|
28 | } |
||
29 | |||
30 | /** |
||
31 | * Sets the language of the EPUB. |
||
32 | */ |
||
33 | 1 | public function setLanguage(string $language): void |
|
44 | } |
||
45 | } |
||
47 |