Test Failed
Push — develop ( 90366f...812a46 )
by Adrien
28:16
created

Run::getHashCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
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
        // Initialise variables
25 30
        $this->setText($pText);
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
    /**
70
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
71
     */
72 View Code Duplication
    public function __clone()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        $vars = get_object_vars($this);
75
        foreach ($vars as $key => $value) {
76
            if (is_object($value)) {
77
                $this->$key = clone $value;
78
            } else {
79
                $this->$key = $value;
80
            }
81
        }
82
    }
83
}
84