Passed
Pull Request — master (#24)
by Anton
02:47 queued 28s
created

NullReacter   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 14
eloc 17
dl 0
loc 86
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A isNotNull() 0 3 1
A isEqualTo() 0 4 1
A isReactedToWithType() 0 5 1
A isNotReactedToWithType() 0 5 1
A isNotEqualTo() 0 4 1
A getId() 0 3 1
A reactTo() 0 5 1
A isNotReactedTo() 0 4 1
A unreactTo() 0 5 1
A __construct() 0 4 1
A getReacterable() 0 3 1
A isReactedTo() 0 4 1
A getReactions() 0 3 1
A isNull() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of Laravel Love.
5
 *
6
 * (c) Anton Komarev <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Cog\Laravel\Love\Reacter\Models;
15
16
use Cog\Contracts\Love\Reactant\Models\Reactant;
17
use Cog\Contracts\Love\Reacter\Exceptions\ReacterInvalid;
18
use Cog\Contracts\Love\Reacter\Models\Reacter as ReacterContract;
19
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract;
20
use Cog\Contracts\Love\ReactionType\Models\ReactionType;
21
use TypeError;
22
23
final class NullReacter implements
24
    ReacterContract
25
{
26
    private $reacterable;
27
28
    public function __construct(
29
        ReacterableContract $reacterable
30
    ) {
31
        $this->reacterable = $reacterable;
32
    }
33
34
    public function getId(): string
35
    {
36
        throw new TypeError();
37
    }
38
39
    public function getReacterable(): ReacterableContract
40
    {
41
        return $this->reacterable;
42
    }
43
44
    public function getReactions(): iterable
45
    {
46
        return [];
47
    }
48
49
    public function reactTo(
50
        Reactant $reactant,
51
        ReactionType $reactionType
52
    ): void {
53
        throw ReacterInvalid::notExists();
54
    }
55
56
    public function unreactTo(
57
        Reactant $reactant,
58
        ReactionType $reactionType
59
    ): void {
60
        throw ReacterInvalid::notExists();
61
    }
62
63
    public function isReactedTo(
64
        Reactant $reactant
65
    ): bool {
66
        return false;
67
    }
68
69
    public function isNotReactedTo(
70
        Reactant $reactant
71
    ): bool {
72
        return true;
73
    }
74
75
    public function isReactedToWithType(
76
        Reactant $reactant,
77
        ReactionType $reactionType
78
    ): bool {
79
        return false;
80
    }
81
82
    public function isNotReactedToWithType(
83
        Reactant $reactant,
84
        ReactionType $reactionType
85
    ): bool {
86
        return true;
87
    }
88
89
    public function isEqualTo(
90
        ReacterContract $that
91
    ): bool {
92
        return $that instanceof self;
93
    }
94
95
    public function isNotEqualTo(
96
        ReacterContract $that
97
    ): bool {
98
        return !$this->isEqualTo($that);
99
    }
100
101
    public function isNull(): bool
102
    {
103
        return true;
104
    }
105
106
    public function isNotNull(): bool
107
    {
108
        return false;
109
    }
110
}
111