| Total Complexity | 4 |
| Total Lines | 32 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | trait XMLStringElementTrait |
||
| 17 | { |
||
| 18 | /** @var string */ |
||
| 19 | protected string $content; |
||
| 20 | |||
| 21 | |||
| 22 | /** |
||
| 23 | * Set the content of the element. |
||
| 24 | * |
||
| 25 | * @param string $content The value to go in the XML textContent |
||
| 26 | * @param array $validators An array of callbacks that may perform validations on the content |
||
| 27 | */ |
||
| 28 | public function setElements(string $content, $validators = []): void |
||
| 29 | { |
||
| 30 | if (!empty($validators)) { |
||
| 31 | foreach ($validators as $validator) { |
||
| 32 | call_user_func($validator, $content); |
||
| 33 | } |
||
| 34 | } |
||
| 35 | |||
| 36 | $this->content = $content; |
||
| 37 | } |
||
| 38 | |||
| 39 | |||
| 40 | /** |
||
| 41 | * Get the content of the element. |
||
| 42 | * |
||
| 43 | * @return string |
||
| 44 | */ |
||
| 45 | public function getContent(): string |
||
| 48 | } |
||
| 49 | } |
||
| 50 |