FileHandler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 5
Bugs 0 Features 2
Metric Value
wmc 4
c 5
b 0
f 2
lcom 1
cbo 3
dl 0
loc 51
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 2
A addFileSet() 0 4 1
A getFileSets() 0 4 1
1
<?php
2
3
namespace Openl10n\Cli\File;
4
5
use Openl10n\Cli\ServiceContainer\Configuration\ConfigurationLoader;
6
7
/**
8
 * Handle the set of FileSet (patterns) defined by user in his config file
9
 */
10
class FileHandler
11
{
12
    /**
13
     * @var ConfigurationLoader
14
     */
15
    protected $configurationLoader;
16
17
    /**
18
     * @var FileSet[]
19
     */
20
    protected $fileSets;
21
22
    /**
23
     * @param ConfigurationLoader $configurationLoader
24
     * @param array $filesConfiguration
25
     */
26
    public function __construct(ConfigurationLoader $configurationLoader, array $filesConfiguration = array())
27
    {
28
        $this->configurationLoader = $configurationLoader;
29
        $this->fileSets = [];
30
31
        foreach ($filesConfiguration as $config) {
32
            $rootDir = $this->configurationLoader->getRootDirectory();
33
            $matcher = new Matcher($config['pattern']);
34
            $options = $config['options'];
35
            $fileSet = new FileSet($rootDir, $matcher, $options);
36
37
            $this->addFileSet($fileSet);
38
        }
39
    }
40
41
    /**
42
     * Add a FileSet to the list handle by this FileHandler
43
     *
44
     * @param FileSet $fileSet
45
     */
46
    public function addFileSet(FileSet $fileSet)
47
    {
48
        $this->fileSets[] = $fileSet;
49
    }
50
51
    /**
52
     * Retrieve FileSet list
53
     *
54
     * @return array|FileSet[]
55
     */
56
    public function getFileSets()
57
    {
58
        return $this->fileSets;
59
    }
60
}
61