Passed
Push — master ( 8b0f6a...fcefc8 )
by Anton
02:48
created

ReactionTotalObserver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 11
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A creating() 0 9 3
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\ReactionTotal\Observers;
15
16
use Cog\Laravel\Love\Reactant\ReactionTotal\Models\ReactionTotal;
17
18
final class ReactionTotalObserver
19
{
20
    public function creating(
21
        ReactionTotal $total
22
    ): void {
23
        if (is_null($total->getAttributeValue('count'))) {
24
            $total->setAttribute('count', ReactionTotal::DEFAULT_COUNT);
25
        }
26
27
        if (is_null($total->getAttributeValue('weight'))) {
28
            $total->setAttribute('weight', ReactionTotal::DEFAULT_WEIGHT);
29
        }
30
    }
31
}
32