Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
TextElement
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
7 / 7
8
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAttribute
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setText
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setLocale
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 renderFirstVisit
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
 renderLastVisit
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace pvc\html\text_node;
4
5use pvc\frmtr\msg\MsgFrmtr;
6use pvc\html\dom\DomElement;
7use pvc\interfaces\frmtr\FrmtrInterface;
8use pvc\interfaces\html\text\DomTextInterface;
9use pvc\interfaces\intl\LocaleInterface;
10use pvc\interfaces\msg\MsgInterface;
11
12class 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}