|
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\Facades; |
|
15
|
|
|
|
|
16
|
|
|
use Cog\Contracts\Love\Reactant\Facades\Reactant as ReacterFacadeContract; |
|
17
|
|
|
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantContract; |
|
18
|
|
|
use Cog\Contracts\Love\Reactant\ReactionCounter\Models\ReactionCounter as ReactionCounterContract; |
|
19
|
|
|
use Cog\Contracts\Love\Reactant\ReactionTotal\Models\ReactionTotal as ReactionTotalContract; |
|
20
|
|
|
use Cog\Contracts\Love\Reacterable\Models\Reacterable as ReacterableContract; |
|
21
|
|
|
use Cog\Laravel\Love\ReactionType\Models\ReactionType; |
|
22
|
|
|
|
|
23
|
|
|
final class Reactant implements ReacterFacadeContract |
|
24
|
|
|
{ |
|
25
|
|
|
private $reactant; |
|
26
|
|
|
|
|
27
|
|
|
public function __construct(ReactantContract $reactant) |
|
28
|
|
|
{ |
|
29
|
|
|
$this->reactant = $reactant; |
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function getReactionCounterOfType( |
|
33
|
|
|
string $reactionTypeName |
|
34
|
|
|
): ReactionCounterContract { |
|
35
|
|
|
return $this->reactant->getReactionCounterOfType( |
|
36
|
|
|
ReactionType::fromName($reactionTypeName) |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
public function getReactionTotal(): ReactionTotalContract |
|
41
|
|
|
{ |
|
42
|
|
|
return $this->reactant->getReactionTotal(); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function isReactedBy( |
|
46
|
|
|
ReacterableContract $reacterable |
|
47
|
|
|
): bool { |
|
48
|
|
|
return $this->reactant->isReactedBy($reacterable->getLoveReacter()); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function isNotReactedBy( |
|
52
|
|
|
ReacterableContract $reacterable |
|
53
|
|
|
): bool { |
|
54
|
|
|
return $this->reactant->isNotReactedBy($reacterable->getLoveReacter()); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
public function isReactedByWithType( |
|
58
|
|
|
ReacterableContract $reacterable, |
|
59
|
|
|
string $reactionTypeName |
|
60
|
|
|
): bool { |
|
61
|
|
|
return $this->reactant->isReactedByWithType( |
|
62
|
|
|
$reacterable->getLoveReacter(), |
|
63
|
|
|
ReactionType::fromName($reactionTypeName) |
|
64
|
|
|
); |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
public function isNotReactedByWithType( |
|
68
|
|
|
ReacterableContract $reacterable, |
|
69
|
|
|
string $reactionTypeName |
|
70
|
|
|
): bool { |
|
71
|
|
|
return $this->reactant->isNotReactedByWithType( |
|
72
|
|
|
$reacterable->getLoveReacter(), |
|
73
|
|
|
ReactionType::fromName($reactionTypeName) |
|
74
|
|
|
); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|