Passed
Push — dev ( b851e4...f48036 )
by Janko
48:24 queued 21:52
created

PirateWrathDecreaser::handle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 0
dl 0
loc 13
ccs 0
cts 9
cp 0
crap 12
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Maintenance;
4
5
use Stu\Orm\Repository\PirateWrathRepositoryInterface;
6
7
final class PirateWrathDecreaser implements MaintenanceHandlerInterface
8
{
9
    public function __construct(
10
        private PirateWrathRepositoryInterface $pirateWrathRepository
11
    ) {
12
    }
13
14
    public function handle(): void
15
    {
16
        foreach ($this->pirateWrathRepository->findAll() as $pirateWrath) {
17
18
            $currentWrath = $pirateWrath->getWrath();
19
            if ($currentWrath <= 100) {
20
                continue;
21
            }
22
23
            $pirateWrath->setWrath(
24
                $currentWrath - 1
25
            );
26
            $this->pirateWrathRepository->save($pirateWrath);
27
        }
28
    }
29
}
30