Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
15 / 15 |
|
100.00% |
10 / 10 |
CRAP | |
100.00% |
1 / 1 |
TextElement | |
100.00% |
15 / 15 |
|
100.00% |
10 / 10 |
12 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setText | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getFont | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
hasHyperlink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getHyperlink | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
setHyperlink | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLanguage | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
setLanguage | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getHashCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | /** |
3 | * This file is part of PHPPresentation - A pure PHP library for reading and writing |
4 | * presentations documents. |
5 | * |
6 | * PHPPresentation is free software distributed under the terms of the GNU Lesser |
7 | * General Public License version 3 as published by the Free Software Foundation. |
8 | * |
9 | * For the full copyright and license information, please read the LICENSE |
10 | * file that was distributed with this source code. For the full list of |
11 | * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
12 | * |
13 | * @see https://github.com/PHPOffice/PHPPresentation |
14 | * |
15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
16 | */ |
17 | |
18 | declare(strict_types=1); |
19 | |
20 | namespace PhpOffice\PhpPresentation\Shape\RichText; |
21 | |
22 | use PhpOffice\PhpPresentation\Shape\Hyperlink; |
23 | use PhpOffice\PhpPresentation\Style\Font; |
24 | |
25 | /** |
26 | * Rich text text element. |
27 | */ |
28 | class TextElement implements TextElementInterface |
29 | { |
30 | /** |
31 | * Text. |
32 | * |
33 | * @var string |
34 | */ |
35 | private $text; |
36 | |
37 | /** |
38 | * @var string |
39 | */ |
40 | protected $language; |
41 | |
42 | /** |
43 | * Hyperlink. |
44 | * |
45 | * @var null|Hyperlink |
46 | */ |
47 | protected $hyperlink; |
48 | |
49 | /** |
50 | * Create a new \PhpOffice\PhpPresentation\Shape\RichText\TextElement instance. |
51 | * |
52 | * @param string $pText Text |
53 | */ |
54 | public function __construct($pText = '') |
55 | { |
56 | // Initialise variables |
57 | $this->text = $pText; |
58 | } |
59 | |
60 | /** |
61 | * Get text. |
62 | * |
63 | * @return string Text |
64 | */ |
65 | public function getText() |
66 | { |
67 | return $this->text; |
68 | } |
69 | |
70 | /** |
71 | * Set text. |
72 | * |
73 | * @param string $pText Text value |
74 | * |
75 | * @return TextElementInterface |
76 | */ |
77 | public function setText($pText = '') |
78 | { |
79 | $this->text = $pText; |
80 | |
81 | return $this; |
82 | } |
83 | |
84 | /** |
85 | * Get font. |
86 | */ |
87 | public function getFont(): ?Font |
88 | { |
89 | return null; |
90 | } |
91 | |
92 | public function hasHyperlink(): bool |
93 | { |
94 | return null !== $this->hyperlink; |
95 | } |
96 | |
97 | public function getHyperlink(): Hyperlink |
98 | { |
99 | if (null === $this->hyperlink) { |
100 | $this->hyperlink = new Hyperlink(); |
101 | } |
102 | |
103 | return $this->hyperlink; |
104 | } |
105 | |
106 | /** |
107 | * Set Hyperlink. |
108 | * |
109 | * @return TextElement |
110 | */ |
111 | public function setHyperlink(?Hyperlink $pHyperlink = null) |
112 | { |
113 | $this->hyperlink = $pHyperlink; |
114 | |
115 | return $this; |
116 | } |
117 | |
118 | /** |
119 | * Get language. |
120 | * |
121 | * @return string |
122 | */ |
123 | public function getLanguage() |
124 | { |
125 | return $this->language; |
126 | } |
127 | |
128 | /** |
129 | * Set language. |
130 | * |
131 | * @param string $language |
132 | * |
133 | * @return TextElement |
134 | */ |
135 | public function setLanguage($language) |
136 | { |
137 | $this->language = $language; |
138 | |
139 | return $this; |
140 | } |
141 | |
142 | /** |
143 | * Get hash code. |
144 | * |
145 | * @return string Hash code |
146 | */ |
147 | public function getHashCode(): string |
148 | { |
149 | return md5($this->text . (null === $this->hyperlink ? '' : $this->hyperlink->getHashCode()) . __CLASS__); |
150 | } |
151 | } |