Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Cell;
4
 
5
class Hyperlink
6
{
7
    /**
8
     * URL to link the cell to.
9
     */
10
    private string $url;
11
 
12
    /**
13
     * Tooltip to display on the hyperlink.
14
     */
15
    private string $tooltip;
16
 
17
    /**
18
     * Create a new Hyperlink.
19
     *
20
     * @param string $url Url to link the cell to
21
     * @param string $tooltip Tooltip to display on the hyperlink
22
     */
23
    public function __construct(string $url = '', string $tooltip = '')
24
    {
25
        // Initialise member variables
26
        $this->url = $url;
27
        $this->tooltip = $tooltip;
28
    }
29
 
30
    /**
31
     * Get URL.
32
     */
33
    public function getUrl(): string
34
    {
35
        return $this->url;
36
    }
37
 
38
    /**
39
     * Set URL.
40
     *
41
     * @return $this
42
     */
43
    public function setUrl(string $url): static
44
    {
45
        $this->url = $url;
46
 
47
        return $this;
48
    }
49
 
50
    /**
51
     * Get tooltip.
52
     */
53
    public function getTooltip(): string
54
    {
55
        return $this->tooltip;
56
    }
57
 
58
    /**
59
     * Set tooltip.
60
     *
61
     * @return $this
62
     */
63
    public function setTooltip(string $tooltip): static
64
    {
65
        $this->tooltip = $tooltip;
66
 
67
        return $this;
68
    }
69
 
70
    /**
71
     * Is this hyperlink internal? (to another worksheet).
72
     */
73
    public function isInternal(): bool
74
    {
75
        return str_contains($this->url, 'sheet://');
76
    }
77
 
78
    public function getTypeHyperlink(): string
79
    {
80
        return $this->isInternal() ? '' : 'External';
81
    }
82
 
83
    /**
84
     * Get hash code.
85
     *
86
     * @return string Hash code
87
     */
88
    public function getHashCode(): string
89
    {
90
        return md5(
91
            $this->url
92
            . $this->tooltip
93
            . __CLASS__
94
        );
95
    }
96
}