DecrementReactionAggregatesJob   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 14
c 0
b 0
f 0
dl 0
loc 35
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A handle() 0 7 1
A getReaction() 0 3 1
A getReactant() 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\Reactant\Jobs;
15
16
use Cog\Contracts\Love\Reactant\Models\Reactant as ReactantInterface;
17
use Cog\Contracts\Love\Reaction\Models\Reaction as ReactionInterface;
18
use Cog\Laravel\Love\Reactant\ReactionCounter\Services\ReactionCounterService;
19
use Cog\Laravel\Love\Reactant\ReactionTotal\Services\ReactionTotalService;
20
use Illuminate\Bus\Queueable;
21
use Illuminate\Contracts\Queue\ShouldQueue as ShouldQueueInterface;
22
use Illuminate\Foundation\Bus\Dispatchable;
23
24
final class DecrementReactionAggregatesJob implements
25
    ShouldQueueInterface
26
{
27
    use Dispatchable;
28
    use Queueable;
29
30
    private ReactantInterface $reactant;
31
32
    private ReactionInterface $reaction;
33
34
    public function __construct(
35
        ReactantInterface $reactant,
36
        ReactionInterface $reaction,
37
    ) {
38
        $this->reactant = $reactant;
39
        $this->reaction = $reaction;
40
    }
41
42
    public function handle(): void
43
    {
44
        (new ReactionCounterService($this->reactant))
45
            ->removeReaction($this->reaction);
46
47
        (new ReactionTotalService($this->reactant))
48
            ->removeReaction($this->reaction);
49
    }
50
51
    public function getReactant(): ReactantInterface
52
    {
53
        return $this->reactant;
54
    }
55
56
    public function getReaction(): ReactionInterface
57
    {
58
        return $this->reaction;
59
    }
60
}
61