Passed
Push — main ( 199c59...bc8763 )
by Daniel
10:26
created

DiscLengthUpdater   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 19
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A update() 0 12 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\Disc;
6
7
use Uxmp\Core\Orm\Model\DiscInterface;
8
use Uxmp\Core\Orm\Repository\DiscRepositoryInterface;
9
10
final class DiscLengthUpdater implements DiscLengthUpdaterInterface
11
{
12 1
    public function __construct(
13
        private DiscRepositoryInterface $discRepository
14
    ) {
15 1
    }
16
17 1
    public function update(
18
        DiscInterface $disc,
19
    ): void {
20 1
        $length = 0;
21
22 1
        foreach ($disc->getSongs() as $song) {
23 1
            $length += $song->getLength();
24
        }
25
26 1
        $disc->setLength($length);
27
28 1
        $this->discRepository->save($disc);
29 1
    }
30
}
31