Test Setup Failed
Branch master (096eb7)
by Phan
03:51
created

LoveTrackOnLastfm::shouldHandle()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace App\Listeners;
4
5
use App\Events\SongLikeToggled;
6
use App\Services\LastfmService;
7
8
class LoveTrackOnLastfm
9
{
10
    protected $lastfm;
11
12
    public function __construct(LastfmService $lastfm)
13
    {
14
        $this->lastfm = $lastfm;
15
    }
16
17
    public function handle(SongLikeToggled $event): void
18
    {
19 View Code Duplication
        if (!$this->lastfm->enabled() ||
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
            !($sessionKey = $event->user->lastfm_session_key) ||
21
            $event->interaction->song->album->artist->is_unknown
22 1
        ) {
23
            return;
24 1
        }
25 1
26
        $this->lastfm->toggleLoveTrack(
27
            $event->interaction->song->title,
28
            $event->interaction->song->album->artist->name,
29
            $sessionKey,
30
            $event->interaction->liked
31
        );
32 1
    }
33
}
34