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

PirateWrathDecreaser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 20
ccs 0
cts 11
cp 0
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 0 13 3
A __construct() 0 3 1
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