Completed
Push — develop ( d383bc...d9bd45 )
by Adrien
23:59
created

Run::setFont()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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