Total Complexity | 9 |
Total Lines | 60 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class TextAtom implements AtomInterface |
||
17 | { |
||
18 | /** @var string */ |
||
19 | private $str; |
||
20 | |||
21 | /** |
||
22 | * @param string $str |
||
23 | */ |
||
24 | public function __construct(string $str) |
||
25 | { |
||
26 | if (!$this->isValidAtom($str)) { |
||
27 | var_dump($str); |
||
|
|||
28 | throw new \InvalidArgumentException('The given String is not a valid Text Atom.'); |
||
29 | } |
||
30 | |||
31 | $this->str = $str; |
||
32 | } |
||
33 | |||
34 | /** {@inheritdoc} */ |
||
35 | public function getFullText(): string |
||
38 | } |
||
39 | |||
40 | /** {@inheritdoc} */ |
||
41 | public function getIdentifier(): string |
||
42 | { |
||
43 | return $this->str; |
||
44 | } |
||
45 | |||
46 | /** {@inheritdoc} */ |
||
47 | public function getInternalIdentifiers(): string |
||
48 | { |
||
49 | throw new \RuntimeException('This Atom has no internal identifiers.'); |
||
50 | } |
||
51 | |||
52 | /** {@inheritdoc} */ |
||
53 | public function hasInternalIdentifiers(): bool |
||
54 | { |
||
55 | return false; |
||
56 | } |
||
57 | |||
58 | /** {@inheritdoc} */ |
||
59 | public function isValidAtom(string $str): bool |
||
60 | { |
||
61 | return \mb_strlen($str) > 0; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @return string |
||
66 | */ |
||
67 | public function __toString(): string |
||
70 | } |
||
71 | |||
72 | /** {@inheritdoc} */ |
||
73 | public function equalsIdentifier(AtomInterface $other): bool |
||
76 | } |
||
77 | } |
||
78 |