Code Duplication    Length = 9-9 lines in 5 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/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
    {

src/Synchronizer.php 1 location

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

src/Services/Spotify.php 1 location

@@ 124-132 (lines=9) @@
121
        return $createdPlaylist->id;
122
    }
123
124
    private function assertValidPlaylistName($name)
125
    {
126
        if (!is_string($name)) {
127
            throw new InvalidArgumentException('The playlist name should be a string, instead got:' . gettype($name));
128
        }
129
        if (empty($name)) {
130
            throw new InvalidArgumentException('The playlist name cannot be empty');
131
        }
132
    }
133
134
    public function replacePlaylistTracks($playlistId, TrackCollection $newTracks, SyncProgress $progress)
135
    {