DownloadAlbumCover::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
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