| Conditions | 3 |
| Paths | 3 |
| Total Lines | 22 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 26 | 2 | public function retrieve(AudioFileInterface $audioFile): ArtistInterface |
|
| 27 | { |
||
| 28 | 2 | $artistMbid = $audioFile->getArtistMbid(); |
|
| 29 | |||
| 30 | 2 | $artist = $this->cache[$artistMbid] ?? null; |
|
| 31 | 2 | if ($artist === null) { |
|
| 32 | 2 | $artist = $this->artistRepository->findByMbId($artistMbid); |
|
| 33 | 2 | if ($artist === null) { |
|
| 34 | 1 | $artist = $this->artistRepository->prototype() |
|
| 35 | 1 | ->setTitle($audioFile->getArtistTitle()) |
|
| 36 | 1 | ->setMbid($artistMbid) |
|
| 37 | 1 | ; |
|
| 38 | } |
||
| 39 | |||
| 40 | 2 | $artist->setSearchTitle($audioFile->getArtistTitleClean()); |
|
| 41 | |||
| 42 | 2 | $this->artistRepository->save($artist); |
|
| 43 | |||
| 44 | 2 | $this->cache[$artistMbid] = $artist; |
|
| 45 | } |
||
| 46 | |||
| 47 | 2 | return $artist; |
|
| 48 | } |
||
| 50 |