Subscription   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 18
dl 0
loc 56
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A location() 0 3 1
A user() 0 3 1
A identity() 0 3 1
A remove() 0 3 1
A name() 0 3 1
A __construct() 0 10 1
A add() 0 10 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace PersonalGalaxy\RSS\Entity;
5
6
use PersonalGalaxy\RSS\{
7
    Entity\Subscription\Identity,
8
    Entity\Subscription\User,
9
    Entity\Subscription\Name,
10
    Event\SubscriptionWasAdded,
11
    Event\SubscriptionWasRemoved,
12
};
13
use Innmind\EventBus\{
14
    ContainsRecordedEventsInterface,
15
    EventRecorder,
16
};
17
use Innmind\Url\UrlInterface;
18
19
final class Subscription implements ContainsRecordedEventsInterface
20
{
21
    use EventRecorder;
22
23
    private $identity;
24
    private $user;
25
    private $name;
26
    private $location;
27
28 5
    private function __construct(
29
        Identity $identity,
30
        User $user,
31
        Name $name,
32
        UrlInterface $location
33
    ) {
34 5
        $this->identity = $identity;
35 5
        $this->user = $user;
36 5
        $this->name = $name;
37 5
        $this->location = $location;
38 5
    }
39
40 5
    public static function add(
41
        Identity $identity,
42
        User $user,
43
        Name $name,
44
        UrlInterface $location
45
    ): self {
46 5
        $self = new self($identity, $user, $name, $location);
47 5
        $self->record(new SubscriptionWasAdded($identity, $user, $name, $location));
48
49 5
        return $self;
50
    }
51
52 3
    public function identity(): Identity
53
    {
54 3
        return $this->identity;
55
    }
56
57 2
    public function user(): User
58
    {
59 2
        return $this->user;
60
    }
61
62 2
    public function name(): Name
63
    {
64 2
        return $this->name;
65
    }
66
67 3
    public function location(): UrlInterface
68
    {
69 3
        return $this->location;
70
    }
71
72 2
    public function remove(): void
73
    {
74 2
        $this->record(new SubscriptionWasRemoved($this->identity));
75 2
    }
76
}
77
78