Passed
Push — main ( 7dcca1...e70bce )
by Daniel
04:22
created

SongDeleter   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Uxmp\Core\Component\Song;
6
7
use Uxmp\Core\Orm\Model\SongInterface;
8
use Uxmp\Core\Orm\Repository\PlaybackHistoryRepositoryInterface;
9
use Uxmp\Core\Orm\Repository\SongRepositoryInterface;
10
11
final readonly class SongDeleter implements SongDeleterInterface
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 11 at column 6
Loading history...
12
{
13 1
    public function __construct(
14
        private SongRepositoryInterface $songRepository,
15
        private PlaybackHistoryRepositoryInterface $playbackHistoryRepository,
16
    ) {
17 1
    }
18
19 1
    public function delete(SongInterface $song): void
20
    {
21 1
        $result = $this->playbackHistoryRepository->findBySong($song);
22
23 1
        foreach ($result as $item) {
24 1
            $this->playbackHistoryRepository->delete($item);
25
        }
26
27 1
        $this->songRepository->delete($song);
28
    }
29
}
30