FolderSyncer::sync()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 2
crap 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