FileSet::getOptions()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
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