FileContainer   A
last analyzed

Complexity

Total Complexity 13

Size/Duplication

Total Lines 152
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 0
dl 0
loc 152
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0

12 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getOutputPath() 0 4 1
A setOutputPath() 0 6 1
A getInputContent() 0 4 1
A setInputContent() 0 6 1
A getInputPath() 0 4 1
A setInputPath() 0 7 1
A getOutputContent() 0 4 1
A setOutputContent() 0 6 1
A getType() 0 4 1
A setType() 0 6 1
A detectInputTypeByInputPath() 0 12 2
1
<?php
2
3
namespace EM\CssCompiler\Container;
4
5
/**
6
 * @see   FileContainerTest
7
 *
8
 * @since 0.1
9
 */
10
class FileContainer
11
{
12
    const TYPE_UNKNOWN = 'unknown';
13
    const TYPE_SCSS    = 'scss';
14
    const TYPE_LESS    = 'less';
15
    public static $supportedTypes = [
16
        self::TYPE_SCSS,
17
        self::TYPE_LESS
18
    ];
19
    /**
20
     * @var string
21
     */
22
    private $inputPath;
23
    /**
24
     * @var string
25
     */
26
    private $outputPath;
27
    /**
28
     * @var string
29
     */
30
    private $inputContent;
31
    /**
32
     * @var string
33
     */
34
    private $outputContent;
35
    /**
36
     * @var string
37
     */
38
    private $type;
39
40
    /**
41
     * @param string $inputPath
42
     * @param string $outputPath
43
     */
44 18
    public function __construct($inputPath, $outputPath)
45
    {
46
        $this
47 18
            ->setInputPath($inputPath)
48 18
            ->setOutputPath($outputPath);
49 18
    }
50
51
    /**
52
     * @return string
53
     */
54 7
    public function getOutputPath()
55
    {
56 7
        return $this->outputPath;
57
    }
58
59
    /**
60
     * @param string $path
61
     *
62
     * @return $this
63
     */
64 18
    public function setOutputPath($path)
65
    {
66 18
        $this->outputPath = $path;
67
68 18
        return $this;
69
    }
70
71
    /**
72
     * @return string
73
     */
74 11
    public function getInputContent()
75
    {
76 11
        return $this->inputContent;
77
    }
78
79
    /**
80
     * @param string $content
81
     *
82
     * @return $this
83
     */
84 12
    public function setInputContent($content)
85
    {
86 12
        $this->inputContent = $content;
87
88 12
        return $this;
89
    }
90
91 18
    public function getInputPath()
92
    {
93 18
        return $this->inputPath;
94
    }
95
96
    /**
97
     * @param string $path
98
     *
99
     * @return $this
100
     */
101 18
    public function setInputPath($path)
102
    {
103 18
        $this->inputPath = $path;
104 18
        $this->detectInputTypeByInputPath();
105
106 18
        return $this;
107
    }
108
109
    /**
110
     * @return string
111
     */
112 13
    public function getOutputContent()
113
    {
114 13
        return $this->outputContent;
115
    }
116
117
    /**
118
     * @param string $content
119
     *
120
     * @return $this
121
     */
122 8
    public function setOutputContent($content)
123
    {
124 8
        $this->outputContent = $content;
125
126 8
        return $this;
127
    }
128
129
    /**
130
     * @return string
131
     */
132 15
    public function getType()
133
    {
134 15
        return $this->type;
135
    }
136
137
    /**
138
     * @param string $type
139
     *
140
     * @return $this
141
     */
142 18
    public function setType($type)
143
    {
144 18
        $this->type = $type;
145
146 18
        return $this;
147
    }
148
149 18
    protected function detectInputTypeByInputPath()
150
    {
151 18
        $extension = strtolower(pathinfo($this->getInputPath(), PATHINFO_EXTENSION));
152
153 18
        $type = in_array($extension, static::$supportedTypes)
154 15
            ? $extension
155 18
            : static::TYPE_UNKNOWN;
156
157 18
        $this->setType($type);
158
159 18
        return $this;
160
    }
161
}
162