Passed
Push — master ( 256ac4...105f15 )
by Anton
03:00
created

IncrementReactionAggregatesJob::getReaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
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 ReactantContract;
17
use Cog\Contracts\Love\Reaction\Models\Reaction as ReactionContract;
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 ShouldQueueContract;
22
use Illuminate\Foundation\Bus\Dispatchable;
23
24
final class IncrementReactionAggregatesJob implements
25
    ShouldQueueContract
26
{
27
    use Dispatchable;
28
    use Queueable;
29
30
    /**
31
     * @var \Cog\Contracts\Love\Reactant\Models\Reactant
32
     */
33
    private $reactant;
34
35
    /**
36
     * @var \Cog\Contracts\Love\Reaction\Models\Reaction
37
     */
38
    private $reaction;
39
40
    /**
41
     * @param \Cog\Contracts\Love\Reactant\Models\Reactant $reactant
42
     * @param \Cog\Contracts\Love\Reaction\Models\Reaction $reaction
43
     */
44
    public function __construct(
45
        ReactantContract $reactant,
46
        ReactionContract $reaction
47
    ) {
48
        $this->reactant = $reactant;
49
        $this->reaction = $reaction;
50
    }
51
52
    public function handle(): void
53
    {
54
        (new ReactionCounterService($this->reactant))
55
            ->addReaction($this->reaction);
56
57
        (new ReactionTotalService($this->reactant))
58
            ->addReaction($this->reaction);
59
    }
60
61
    /**
62
     * @return ReactantContract
63
     */
64
    public function getReactant(): ReactantContract
65
    {
66
        return $this->reactant;
67
    }
68
69
    /**
70
     * @return ReactionContract
71
     */
72
    public function getReaction(): ReactionContract
73
    {
74
        return $this->reaction;
75
    }
76
}
77