Completed
Push — master ( d12e81...783e24 )
by Hans
15:28
created

Synchronizer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4286
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
3
namespace HansOtt\Lastify;
4
5
use HansOtt\Lastify\LastFm\LastFmConnection;
6
use HansOtt\Lastify\Spotify\SpotifyConnection;
7
8
class Synchronizer
9
{
10
    private $target;
11
    private $source;
12
13
    public function __construct(SpotifyConnection $spotify, LastFmConnection $lastFm)
14
    {
15
        $this->target = $spotify;
16
        $this->source = $lastFm;
17
    }
18
19
    public function syncTopTracksToPlaylist($playlistName, $limit = 10)
20
    {
21
        $spotifyPlaylist = $this->target->createPlaylistIfNotExists($playlistName);
22
        $tracks = $this->source->getTopTracks($limit);
23
        $this->target->updatePlaylistTracks($spotifyPlaylist, $tracks);
24
    }
25
}
26