EventStreamFeedLink   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 53
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUri() 0 4 1
A getRelation() 0 4 1
A __construct() 0 8 2
1
<?php
2
3
namespace RayRutjes\GetEventStore\Client\Http\Feed;
4
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
46
    {
47
        return $this->uri;
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getRelation(): string
54
    {
55
        return $this->relation;
56
    }
57
}
58