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