Passed
Push — develop ( b05d07...17d4a5 )
by Adrien
26:16
created

Hyperlink::getTypeHyperlink()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 2
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Cell;
4
5
class Hyperlink
6
{
7
    /**
8
     * URL to link the cell to.
9
     *
10
     * @var string
11
     */
12
    private $url;
13
14
    /**
15
     * Tooltip to display on the hyperlink.
16
     *
17
     * @var string
18
     */
19
    private $tooltip;
20
21
    /**
22
     * Create a new Hyperlink.
23
     *
24
     * @param string $pUrl Url to link the cell to
25
     * @param string $pTooltip Tooltip to display on the hyperlink
26
     */
27 29
    public function __construct($pUrl = '', $pTooltip = '')
28
    {
29
        // Initialise member variables
30 29
        $this->url = $pUrl;
31 29
        $this->tooltip = $pTooltip;
32 29
    }
33
34
    /**
35
     * Get URL.
36
     *
37
     * @return string
38
     */
39 21
    public function getUrl()
40
    {
41 21
        return $this->url;
42
    }
43
44
    /**
45
     * Set URL.
46
     *
47
     * @param string $value
48
     *
49
     * @return Hyperlink
50
     */
51 23
    public function setUrl($value)
52
    {
53 23
        $this->url = $value;
54
55 23
        return $this;
56
    }
57
58
    /**
59
     * Get tooltip.
60
     *
61
     * @return string
62
     */
63 16
    public function getTooltip()
64
    {
65 16
        return $this->tooltip;
66
    }
67
68
    /**
69
     * Set tooltip.
70
     *
71
     * @param string $value
72
     *
73
     * @return Hyperlink
74
     */
75 14
    public function setTooltip($value)
76
    {
77 14
        $this->tooltip = $value;
78
79 14
        return $this;
80
    }
81
82
    /**
83
     * Is this hyperlink internal? (to another worksheet).
84
     *
85
     * @return bool
86
     */
87 17
    public function isInternal()
88
    {
89 17
        return strpos($this->url, 'sheet://') !== false;
90
    }
91
92
    /**
93
     * @return string
94
     */
95 2
    public function getTypeHyperlink()
96
    {
97 2
        return $this->isInternal() ? '' : 'External';
98
    }
99
100
    /**
101
     * Get hash code.
102
     *
103
     * @return string Hash code
104
     */
105 1
    public function getHashCode()
106
    {
107 1
        return md5(
108 1
            $this->url .
109 1
            $this->tooltip .
110 1
            __CLASS__
111
        );
112
    }
113
}
114