NullReactionCounter   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 16
c 1
b 0
f 0
dl 0
loc 69
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A decrementWeight() 0 4 1
A getReactant() 0 3 1
A __construct() 0 6 1
A isNotReactionOfType() 0 4 1
A incrementCount() 0 4 1
A getReactionType() 0 3 1
A getCount() 0 3 1
A getWeight() 0 3 1
A decrementCount() 0 4 1
A incrementWeight() 0 4 1
A isReactionOfType() 0 4 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\Reactant\ReactionCounter\Models;
15
16
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantInterface;
17
use Cog\Contracts\Love\Reactant\ReactionCounter\Exceptions\ReactionCounterInvalid;
18
use Cog\Contracts\Love\Reactant\ReactionCounter\Models\ReactionCounter as ReactionCounterInterface;
19
use Cog\Contracts\Love\ReactionType\Models\ReactionType as ReactionTypeInterface;
20
21
final class NullReactionCounter implements
22
    ReactionCounterInterface
23
{
24
    private ReactantInterface $reactant;
25
26
    private ReactionTypeInterface $reactionType;
27
28
    public function __construct(
29
        ReactantInterface $reactant,
30
        ReactionTypeInterface $reactionType,
31
    ) {
32
        $this->reactant = $reactant;
33
        $this->reactionType = $reactionType;
34
    }
35
36
    public function getReactant(): ReactantInterface
37
    {
38
        return $this->reactant;
39
    }
40
41
    public function getReactionType(): ReactionTypeInterface
42
    {
43
        return $this->reactionType;
44
    }
45
46
    public function isReactionOfType(
47
        ReactionTypeInterface $reactionType,
48
    ): bool {
49
        return $this->getReactionType()->isEqualTo($reactionType);
50
    }
51
52
    public function isNotReactionOfType(
53
        ReactionTypeInterface $reactionType,
54
    ): bool {
55
        return !$this->isReactionOfType($reactionType);
56
    }
57
58
    public function getCount(): int
59
    {
60
        return 0;
61
    }
62
63
    public function getWeight(): float
64
    {
65
        return 0.0;
66
    }
67
68
    public function incrementCount(
69
        int $amount,
70
    ): void {
71
        throw ReactionCounterInvalid::notExists();
72
    }
73
74
    public function decrementCount(
75
        int $amount,
76
    ): void {
77
        throw ReactionCounterInvalid::notExists();
78
    }
79
80
    public function incrementWeight(
81
        float $amount,
82
    ): void {
83
        throw ReactionCounterInvalid::notExists();
84
    }
85
86
    public function decrementWeight(
87
        float $amount,
88
    ): void {
89
        throw ReactionCounterInvalid::notExists();
90
    }
91
}
92