Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| TextElement | |
100.00% |
7 / 7 |
|
100.00% |
7 / 7 |
8 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAttribute | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setLocale | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| renderFirstVisit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| renderLastVisit | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace pvc\html\text_node; |
| 4 | |
| 5 | use pvc\frmtr\msg\MsgFrmtr; |
| 6 | use pvc\html\dom\DomElement; |
| 7 | use pvc\interfaces\frmtr\FrmtrInterface; |
| 8 | use pvc\interfaces\html\text\DomTextInterface; |
| 9 | use pvc\interfaces\intl\LocaleInterface; |
| 10 | use pvc\interfaces\msg\MsgInterface; |
| 11 | |
| 12 | class TextElement extends DomElement implements DomTextInterface |
| 13 | { |
| 14 | protected string|MsgInterface $text; |
| 15 | |
| 16 | /** |
| 17 | * @param MsgFrmtr $msgFrmtr |
| 18 | */ |
| 19 | public function __construct( |
| 20 | protected FrmtrInterface $msgFrmtr, |
| 21 | ) |
| 22 | { |
| 23 | } |
| 24 | |
| 25 | public function getName(): string |
| 26 | { |
| 27 | return 'text_node'; |
| 28 | } |
| 29 | |
| 30 | /** |
| 31 | * @param string $name |
| 32 | * |
| 33 | * @return null |
| 34 | */ |
| 35 | public function getAttribute(string $name): null |
| 36 | { |
| 37 | return null; |
| 38 | } |
| 39 | |
| 40 | public function setText(string|MsgInterface $text): void |
| 41 | { |
| 42 | $this->text = $text; |
| 43 | } |
| 44 | |
| 45 | public function setLocale(LocaleInterface $locale): void |
| 46 | { |
| 47 | $this->msgFrmtr->setLocale($locale); |
| 48 | } |
| 49 | |
| 50 | public function renderFirstVisit(): string |
| 51 | { |
| 52 | return ($this->text instanceof MsgInterface) ? $this->msgFrmtr->format($this->text) : $this->text; |
| 53 | } |
| 54 | |
| 55 | public function renderLastVisit(): string |
| 56 | { |
| 57 | return ''; |
| 58 | } |
| 59 | } |