| Conditions | 3 |
| Paths | 3 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 18 |
| CRAP Score | 3 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 24 | 2 | public function delete( |
|
| 25 | Interactor $io, |
||
| 26 | int $catalogId |
||
| 27 | ): void { |
||
| 28 | 2 | $catalog = $this->catalogRepository->find($catalogId); |
|
| 29 | 2 | if ($catalog === null) { |
|
| 30 | 1 | $io->error( |
|
| 31 | 1 | sprintf('Catalog `%d` not found', $catalogId), |
|
| 32 | 1 | true |
|
| 33 | 1 | ); |
|
| 34 | 1 | return; |
|
| 35 | } |
||
| 36 | |||
| 37 | 1 | $io->info('Cleaning catalog', true); |
|
| 38 | |||
| 39 | 1 | $albums = $this->albumRepository->findBy(['catalog' => $catalog]); |
|
| 40 | |||
| 41 | 1 | foreach ($albums as $album) { |
|
| 42 | 1 | $io->info( |
|
| 43 | 1 | sprintf('Deleting album `%s`', $album->getTitle()), |
|
| 44 | 1 | true |
|
| 45 | 1 | ); |
|
| 46 | |||
| 47 | 1 | $this->albumDeleter->delete($album); |
|
| 48 | } |
||
| 49 | |||
| 50 | 1 | $this->catalogRepository->delete($catalog); |
|
| 51 | |||
| 52 | 1 | $io->ok('Done', true); |
|
| 53 | } |
||
| 55 |