1 | <?php |
||
48 | abstract class AbstractRelation implements RelationInterface |
||
49 | { |
||
50 | /** |
||
51 | * Relation type |
||
52 | * |
||
53 | * @var string |
||
54 | */ |
||
55 | const TYPE = 'abstract'; |
||
56 | /** |
||
57 | * Relation URL |
||
58 | * |
||
59 | * @var Url|ApparatUrl |
||
60 | */ |
||
61 | protected $url = null; |
||
62 | /** |
||
63 | * Relation label |
||
64 | * |
||
65 | * @var string |
||
66 | */ |
||
67 | protected $label = null; |
||
68 | /** |
||
69 | * Relation email |
||
70 | * |
||
71 | * @var string |
||
72 | */ |
||
73 | protected $email = null; |
||
74 | /** |
||
75 | * Coupling |
||
76 | * |
||
77 | * @var int |
||
78 | */ |
||
79 | protected $coupling = self::LOOSE_COUPLING; |
||
80 | |||
81 | /** |
||
82 | * @param Url $url Relation URL |
||
83 | * @param string $label Relation label |
||
84 | * @param string $email Relation email |
||
85 | * @param int $coupling Coupling |
||
86 | * @throws OutOfBoundsException If the object coupling is invalid |
||
87 | */ |
||
88 | 40 | public function __construct( |
|
107 | |||
108 | /** |
||
109 | * Return the URL |
||
110 | * |
||
111 | * @return Url|ApparatUrl URL |
||
112 | */ |
||
113 | 3 | public function getUrl() |
|
117 | |||
118 | /** |
||
119 | * Set the URL |
||
120 | * |
||
121 | * @param Url|ApparatUrl|null $url URL |
||
122 | * @return RelationInterface Self reference |
||
123 | */ |
||
124 | 1 | public function setUrl(Url $url = null) |
|
130 | |||
131 | /** |
||
132 | * Return the label |
||
133 | * |
||
134 | * @return string|null Label |
||
135 | */ |
||
136 | 1 | public function getLabel() |
|
140 | |||
141 | /** |
||
142 | * Set the label |
||
143 | * |
||
144 | * @param string|null $label Label |
||
145 | * @return RelationInterface Self reference |
||
146 | */ |
||
147 | 1 | public function setLabel($label) |
|
153 | |||
154 | /** |
||
155 | * Return the email address |
||
156 | * |
||
157 | * @return string|null Email address |
||
158 | */ |
||
159 | 2 | public function getEmail() |
|
163 | |||
164 | /** |
||
165 | * Set the email address |
||
166 | * |
||
167 | * @param string|null $email Email address |
||
168 | * @return RelationInterface Self reference |
||
169 | */ |
||
170 | 1 | public function setEmail($email) |
|
176 | |||
177 | /** |
||
178 | * Return the coupling |
||
179 | * |
||
180 | * @return int Coupling |
||
181 | */ |
||
182 | 1 | public function getCoupling() |
|
186 | |||
187 | /** |
||
188 | * Set the coupling |
||
189 | * |
||
190 | * @param int $coupling Coupling |
||
191 | * @return RelationInterface Self reference |
||
192 | * @throws OutOfBoundsException If the object coupling is invalid |
||
193 | */ |
||
194 | 1 | public function setCoupling($coupling) |
|
208 | |||
209 | /** |
||
210 | * Return the unique relation signature |
||
211 | * |
||
212 | * @return string Relation signature |
||
213 | */ |
||
214 | 38 | public function getSignature() |
|
215 | { |
||
216 | 38 | return md5( |
|
217 | 38 | $this->getRelationType(). |
|
218 | (empty($this->url) |
||
219 | 11 | ? (empty($this->email) ? (empty($this->label) ? '-' : $this->label) : $this->email) |
|
220 | 38 | : $this->url) |
|
221 | ); |
||
222 | } |
||
223 | |||
224 | /** |
||
225 | * Return the relation type |
||
226 | * |
||
227 | * @return string Relation type |
||
228 | */ |
||
229 | 38 | public function getRelationType() |
|
233 | |||
234 | /** |
||
235 | * Serialize the property |
||
236 | * |
||
237 | * @return mixed Property serialization |
||
238 | */ |
||
239 | 4 | public function __toString() |
|
244 | } |
||
245 |