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
|
|
|
|