FileSet   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getFiles() 0 4 1
A getOptions() 0 12 3
1
<?php
2
3
namespace Openl10n\Cli\File;
4
5
/**
6
 * Wrap a user defined pattern and give access to files
7
 */
8
class FileSet
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $rootDirectory;
14
15
    /**
16
     * @var Matcher
17
     */
18
    protected $matcher;
19
20
    /**
21
     * @var array
22
     */
23
    protected $options;
24
25
    /**
26
     * @param string  $rootDirectory
27
     * @param Matcher $matcher
28
     * @param array   $options
29
     */
30
    public function __construct($rootDirectory, Matcher $matcher, array $options = array())
31
    {
32
        $this->rootDirectory = $rootDirectory;
33
        $this->matcher = $matcher;
34
        $this->options = $options;
35
    }
36
37
    /**
38
     * Retrieve files match by user pattern
39
     *
40
     * @return FileInfo[]
41
     */
42
    public function getFiles()
43
    {
44
        return $this->matcher->match($this->rootDirectory);
45
    }
46
47
    /**
48
     * Retrieve options associated to this pattern
49
     *
50
     * @param null $key
51
     *
52
     * @return array
53
     */
54
    public function getOptions($key = null)
55
    {
56
        if (null === $key) {
57
            return $this->options;
58
        }
59
60
        if (!isset($this->options[$key])) {
61
            return array();
62
        }
63
64
        return $this->options[$key];
65
    }
66
}
67