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

getPersistentSubscriptionInfo()   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
use RayRutjes\GetEventStore\PersistentSubscriptionInfo;
6
7
final class PersistentSubscriptionInfoFeed
8
{
9
    /**
10
     * @var array
11
     */
12
    private $links = [];
13
14
    /**
15
     * @var PersistentSubscriptionInfo
16
     */
17
    private $info;
18
19
    /**
20
     * @param array                      $links
21
     * @param PersistentSubscriptionInfo $info
22
     */
23
    public function __construct(array $links, PersistentSubscriptionInfo $info)
24
    {
25
        foreach ($links as $link) {
26
            $this->validateLink($link);
27
            $this->links[$link->getRelation()] = $link;
28
        }
29
        $this->info = $info;
30
    }
31
32
    /**
33
     * @param $link
34
     */
35 View Code Duplication
    private function validateLink($link)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        if (!$link instanceof PersistentSubscriptionInfoFeedLink) {
38
            throw new \InvalidArgumentException('Invalid link type %s.', get_class($link));
39
        }
40
        if (isset($this->links[$link->getRelation()])) {
41
            throw new \InvalidArgumentException(sprintf('Link relation %s already there.', $link->getRelation()));
42
        }
43
    }
44
45
    /**
46
     * @return PersistentSubscriptionInfo
47
     */
48
    public function getPersistentSubscriptionInfo(): PersistentSubscriptionInfo
49
    {
50
        return $this->info;
51
    }
52
}
53