FileInfo   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 6
c 4
b 0
f 1
lcom 1
cbo 1
dl 0
loc 50
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getAbsolutePathname() 0 4 1
A getRelativePathname() 0 4 1
A getPathname() 0 6 1
A getAttribute() 0 8 2
1
<?php
2
3
namespace Openl10n\Cli\File;
4
5
class FileInfo
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $rootDirectory;
11
12
    /**
13
     * @var Pattern
14
     */
15
    protected $pattern;
16
17
    /**
18
     * @var array
19
     */
20
    protected $attributes;
21
22
    public function __construct($rootDirectory, Pattern $pattern, array $attributes)
23
    {
24
        $this->rootDirectory = $rootDirectory;
25
        $this->pattern = $pattern;
26
        $this->attributes = $attributes;
27
    }
28
29
    public function getAbsolutePathname()
30
    {
31
        return realpath($this->rootDirectory.DIRECTORY_SEPARATOR.$this->getPathname());
32
    }
33
34
    public function getRelativePathname()
35
    {
36
        return $this->getPathname();
37
    }
38
39
    public function getPathname(array $usingAttributes = array())
40
    {
41
        $attributes = array_merge($this->attributes, $usingAttributes);
42
43
        return $this->pattern->toString($attributes);
44
    }
45
46
    public function getAttribute($name)
47
    {
48
        if (!isset($this->attributes[$name])) {
49
            throw new \InvalidArgumentException(sprintf('Attribute %s does not exist', $name));
50
        }
51
52
        return $this->attributes[$name];
53
    }
54
}
55