FolderSyncer   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 27
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sync() 0 7 2
1
<?php
2
3
namespace SyncFS\Syncer;
4
5
use SyncFS\Client\ClientInterface;
6
use SyncFS\Map\FileSystemMap;
7
use SyncFS\Map\MapBag;
8
9
/**
10
 * Class FolderSyncer
11
 *
12
 * @package SyncFS\Syncer
13
 * @author  Matej Velikonja <[email protected]>
14
 */
15
class FolderSyncer
16
{
17
    /**
18
     * @var \SyncFS\Client\ClientInterface
19
     */
20
    private $client;
21
22
    /**
23
     * @param ClientInterface $client
24
     */
25 3
    public function __construct(ClientInterface $client)
26
    {
27 3
        $this->client = $client;
28 3
    }
29
30
    /**
31
     * @param MapBag   $folders
32
     * @param Callable $callback
33
     */
34 3
    public function sync(MapBag $folders, $callback = null)
35
    {
36
        /** @var FileSystemMap $folder */
37 3
        foreach ($folders->all() as $folder) {
38 3
            $this->client->sync($folder->getSource(), $folder->getDestination(), $callback);
39 3
        }
40 3
    }
41
}
42