Completed
Pull Request — master (#1)
by Raymond
03:07
created

AbstractFeedLink::getRelation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace RayRutjes\GetEventStore\Client\Http\Feed;
4
5
abstract class AbstractFeedLink
6
{
7
    /**
8
     * @var string
9
     */
10
    private $uri;
11
12
    /**
13
     * @var string
14
     */
15
    private $relation;
16
17
    /**
18
     * @param string $uri
19
     * @param string $relation
20
     */
21
    final public function __construct(string $uri, string $relation)
22
    {
23
        $validRelations = $this->getValidRelations();
24
        if (!in_array($relation, $validRelations)) {
25
            throw new \InvalidArgumentException(sprintf('Invalid link relation %s.', $relation));
26
        }
27
        $this->uri = $uri;
28
        $this->relation = $relation;
29
    }
30
31
    /**
32
     * @return array
33
     */
34
    abstract protected function getValidRelations(): array;
35
36
    /**
37
     * @return string
38
     */
39
    final public function getUri(): string
40
    {
41
        return $this->uri;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    final public function getRelation(): string
48
    {
49
        return $this->relation;
50
    }
51
}
52