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

PirateWrathDecreaser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 1
cp 0
crap 2
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