Failed Conditions
Pull Request — master (#4487)
by Owen
18:03 queued 10:33
created

TextElement::getFont()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\RichText;
4
5
use PhpOffice\PhpSpreadsheet\Style\Font;
6
7
class TextElement implements ITextElement
8
{
9
    /**
10
     * Text.
11
     */
12
    private string $text;
13
14
    /**
15
     * Create a new TextElement instance.
16
     *
17
     * @param string $text Text
18
     */
19 269
    public function __construct(string $text = '')
20
    {
21
        // Initialise variables
22 269
        $this->text = $text;
23
    }
24
25
    /**
26
     * Get text.
27
     *
28
     * @return string Text
29
     */
30 239
    public function getText(): string
31
    {
32 239
        return $this->text;
33
    }
34
35
    /**
36
     * Set text.
37
     *
38
     * @param string $text Text
39
     *
40
     * @return $this
41
     */
42 11
    public function setText(string $text): self
43
    {
44 11
        $this->text = $text;
45
46 11
        return $this;
47
    }
48
49
    /**
50
     * Get font. For this class, the return value is always null.
51
     */
52 3
    public function getFont(): ?Font
53
    {
54 3
        return null;
55
    }
56
57
    /**
58
     * Get hash code.
59
     *
60
     * @return string Hash code
61
     */
62 17
    public function getHashCode(): string
63
    {
64 17
        return md5(
65 17
            $this->text
66 17
            . __CLASS__
67 17
        );
68
    }
69
}
70