| Total Complexity | 2 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | final class DeferredFragmentInjection implements XmlInjectable |
||
| 13 | { |
||
| 14 | /** |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | private $parentNS; |
||
| 18 | /** |
||
| 19 | * @var string |
||
| 20 | */ |
||
| 21 | private $parentTagName; |
||
| 22 | /** |
||
| 23 | * @var Closure |
||
| 24 | */ |
||
| 25 | private $fragment; |
||
| 26 | |||
| 27 | 7 | public function inject(DOMDocument $dom): void |
|
| 28 | { |
||
| 29 | 7 | $elements = $dom->getElementsByTagNameNS($this->parentNS, $this->parentTagName); |
|
| 30 | |||
| 31 | 7 | $fragment = $dom->createDocumentFragment(); |
|
| 32 | 7 | $fragment->appendXML(call_user_func($this->fragment)); |
|
| 33 | |||
| 34 | 7 | $elements->item(0)->appendChild($fragment); |
|
| 35 | 7 | } |
|
| 36 | |||
| 37 | 8 | public function __construct(string $parentNS, string $parentTagName, Closure $fragment) |
|
| 42 | 8 | } |
|
| 43 | } |
||
| 44 |