DownloadAlbumCover   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A handle() 0 10 4
1
<?php
2
3
namespace App\Listeners;
4
5
use App\Events\AlbumInformationFetched;
6
use App\Services\MediaMetadataService;
7
8
class DownloadAlbumCover
9
{
10
    private $mediaMetadataService;
11
12 1
    public function __construct(MediaMetadataService $mediaMetadataService)
13
    {
14 1
        $this->mediaMetadataService = $mediaMetadataService;
15 1
    }
16
17 1
    public function handle(AlbumInformationFetched $event): void
18
    {
19 1
        $info = $event->getInformation();
20 1
        $album = $event->getAlbum();
21
22 1
        $image = array_get($info, 'image');
23
24
        // If our current album has no cover, and Last.fm has one, steal it?
25 1
        if (!$album->has_cover && is_string($image) && ini_get('allow_url_fopen')) {
26 1
            $this->mediaMetadataService->downloadAlbumCover($album, $image);
27
        }
28 1
    }
29
}
30