1 | <?php |
||
5 | class EventStreamFeedLink |
||
6 | { |
||
7 | const LINK_SELF = 'self'; |
||
8 | const LINK_FIRST = 'first'; |
||
9 | const LINK_LAST = 'last'; |
||
10 | const LINK_PREVIOUS = 'previous'; |
||
11 | const LINK_NEXT = 'next'; |
||
12 | const LINK_METADATA = 'metadata'; |
||
13 | |||
14 | /** |
||
15 | * @var array |
||
16 | */ |
||
17 | private $validRelations = [self::LINK_SELF, self::LINK_FIRST, self::LINK_LAST, self::LINK_PREVIOUS, self::LINK_NEXT, self::LINK_METADATA]; |
||
18 | |||
19 | /** |
||
20 | * @var string |
||
21 | */ |
||
22 | private $uri; |
||
23 | |||
24 | /** |
||
25 | * @var string |
||
26 | */ |
||
27 | private $relation; |
||
28 | |||
29 | /** |
||
30 | * @param string $uri |
||
31 | * @param string $relation |
||
32 | */ |
||
33 | public function __construct(string $uri, string $relation) |
||
34 | { |
||
35 | if (!in_array($relation, $this->validRelations)) { |
||
36 | throw new \InvalidArgumentException(sprintf('Invalid link relation %s.', $relation)); |
||
37 | } |
||
38 | $this->uri = $uri; |
||
39 | $this->relation = $relation; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * @return string |
||
44 | */ |
||
45 | public function getUri(): string |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | public function getRelation(): string |
||
57 | } |
||
58 |