DecrementAggregates   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 8 1
A __construct() 0 4 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\Listeners;
15
16
use Cog\Laravel\Love\Reactant\Jobs\DecrementReactionAggregatesJob;
17
use Cog\Laravel\Love\Reaction\Events\ReactionHasBeenRemoved;
18
use Illuminate\Contracts\Bus\Dispatcher as DispatcherInterface;
19
20
final class DecrementAggregates
21
{
22
    private DispatcherInterface $dispatcher;
23
24
    public function __construct(
25
        DispatcherInterface $dispatcher,
26
    ) {
27
        $this->dispatcher = $dispatcher;
28
    }
29
30
    public function handle(
31
        ReactionHasBeenRemoved $event,
32
    ): void {
33
        $reaction = $event->getReaction();
34
        $reactant = $reaction->getReactant();
35
36
        $this->dispatcher->dispatch(
37
            new DecrementReactionAggregatesJob($reactant, $reaction),
38
        );
39
    }
40
}
41