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

Synchronizer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A syncTopTracksToPlaylist() 0 6 1
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