]>
Commit | Line | Data |
---|---|---|
88564339 AS |
1 | <?php |
2 | /** | |
3 | * link.php | |
4 | * | |
5 | * Copyright 2018 Andy Street <andy@street.me.uk> | |
6 | * | |
7 | * This program is free software; you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published by | |
9 | * the Free Software Foundation; either version 2 of the License, or | |
10 | * (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with this program; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | |
20 | * MA 02110-1301, USA. | |
21 | * | |
22 | * | |
23 | */ | |
24 | ||
25 | namespace libgpx; | |
26 | ||
27 | /** | |
28 | * A link to an external resource (Web page, digital photo, video clip, etc) | |
29 | * with additional information. | |
30 | * | |
31 | * @see https://www.topografix.com/GPX/1/1/#type_linkType | |
32 | * | |
33 | * @author Andy Street <andy@street.me.uk> | |
34 | */ | |
35 | class Link | |
36 | { | |
37 | ||
38 | /** | |
39 | * URL of hyperlink. | |
40 | * | |
41 | * @var string | |
42 | */ | |
43 | protected $href; | |
44 | ||
45 | /** | |
46 | * Text of hyperlink. | |
47 | * | |
48 | * @var string | |
49 | */ | |
50 | protected $text; | |
51 | ||
52 | /** | |
53 | * Mime type of content (image/jpeg). | |
54 | * | |
55 | * @var string | |
56 | */ | |
57 | protected $type; | |
58 | ||
59 | /** | |
60 | * Create a new link. | |
61 | * | |
62 | * @param string $href The URL of the link. | |
63 | */ | |
64 | public function __construct(string $href) | |
65 | { | |
66 | $this->setHref($href); | |
67 | } | |
68 | ||
69 | /** | |
70 | * Fetch the URL of the link. | |
71 | * | |
72 | * @return string | |
73 | */ | |
74 | public function getHref() | |
75 | { | |
76 | return $this->href; | |
77 | } | |
78 | ||
79 | /** | |
80 | * Set the URL of the link. | |
81 | * | |
82 | * @param string $href The URL of the link. | |
83 | * @return void | |
84 | */ | |
85 | public function setHref(string $href) | |
86 | { | |
87 | $this->href = $href; | |
88 | } | |
89 | ||
90 | /** | |
91 | * Fetch the text of the hyperlink. | |
92 | * | |
93 | * @return string|null The text or null if not set. | |
94 | */ | |
95 | public function getText() | |
96 | { | |
97 | return $this->text; | |
98 | } | |
99 | ||
100 | /** | |
101 | * Set the text of the hyperlink. | |
102 | * | |
103 | * @param string|null $text The text of the link or null to delete. | |
104 | * @return void | |
105 | */ | |
106 | public function setText(string $text = null) | |
107 | { | |
108 | $this->text = $text; | |
109 | } | |
110 | ||
111 | /** | |
112 | * Fetch the mime type of the hyperlink. | |
113 | * | |
114 | * @return string|null The mime type or null if not set. | |
115 | */ | |
116 | public function getType() | |
117 | { | |
118 | return $this->type; | |
119 | } | |
120 | ||
121 | /** | |
122 | * Set the mime type of the hyperlink. | |
123 | * | |
124 | * @param string|null $type The mime type of the link or null to delete. | |
125 | * @return void | |
126 | */ | |
127 | public function setType(string $type = null) | |
128 | { | |
129 | $this->type = $type; | |
130 | } | |
131 | ||
132 | } |