IncrementReactionAggregatesJob::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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 IncrementReactionAggregatesJob 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
            ->addReaction($this->reaction);
46
47
        (new ReactionTotalService($this->reactant))
48
            ->addReaction($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