Code Duplication    Length = 9-10 lines in 6 locations

src/Services/LastFm.php 1 location

@@ 61-69 (lines=9) @@
58
        return new TrackInfo($track->name, [$artist]);
59
    }
60
61
    private function assertValidUsername($username)
62
    {
63
        if (!is_string($username)) {
64
            throw new InvalidArgumentException('The username should be a string, instead got:' . gettype($username));
65
        }
66
        if (empty($username)) {
67
            throw new InvalidArgumentException('The username cannot be empty');
68
        }
69
    }
70
71
    public function getTopTracks($username, $limit = 50)
72
    {

src/Services/Spotify.php 2 locations

@@ 35-44 (lines=10) @@
32
        return new static($api);
33
    }
34
35
    private static function assertValidAccessToken($accessToken)
36
    {
37
        if (!is_string($accessToken)) {
38
            throw new InvalidArgumentException('The access token should be a string, instead got:' . gettype($accessToken));
39
        }
40
41
        if (empty($accessToken)) {
42
            throw new InvalidArgumentException('The access token cannot be empty');
43
        }
44
    }
45
46
    private function getSearchQuery(TrackInfo $info)
47
    {
@@ 123-131 (lines=9) @@
120
        return $createdPlaylist->id;
121
    }
122
123
    private function assertValidPlaylistName($name)
124
    {
125
        if (!is_string($name)) {
126
            throw new InvalidArgumentException('The playlist name should be a string, instead got:' . gettype($name));
127
        }
128
        if (empty($name)) {
129
            throw new InvalidArgumentException('The playlist name cannot be empty');
130
        }
131
    }
132
133
    public function replacePlaylistTracks($playlistId, TrackCollection $newTracks, SyncProgress $progress)
134
    {

src/Synchronizer.php 1 location

@@ 47-55 (lines=9) @@
44
     *
45
     * @param string $name
46
     */
47
    private function assertValidPlaylistName($name)
48
    {
49
        if (!is_string($name)) {
50
            throw new InvalidArgumentException('The playlist name should be a string, instead got:' . gettype($name));
51
        }
52
        if (empty($name)) {
53
            throw new InvalidArgumentException('The playlist name cannot be empty');
54
        }
55
    }
56
57
    /**
58
     * Get the playlist id of a playlist.

src/TrackInfo.php 1 location

@@ 22-30 (lines=9) @@
19
        $this->artists = $artists;
20
    }
21
22
    private function assertValidName($name)
23
    {
24
        if (!is_string($name)) {
25
            throw new InvalidArgumentException('The name should be a string, instead got:' . gettype($name));
26
        }
27
        if (empty($name)) {
28
            throw new InvalidArgumentException('The name cannot be empty');
29
        }
30
    }
31
32
    private function assertThatTheseAreAllArtists(array $artists)
33
    {

src/TrackInfo/Artist.php 1 location

@@ 17-25 (lines=9) @@
14
        $this->name = $name;
15
    }
16
17
    private function assertValidName($name)
18
    {
19
        if (!is_string($name)) {
20
            throw new InvalidArgumentException('The name should be a string, instead got:' . gettype($name));
21
        }
22
        if (empty($name)) {
23
            throw new InvalidArgumentException('The name cannot be empty');
24
        }
25
    }
26
27
    public function getName()
28
    {