Test Failed
Push — master ( a58c94...1bcec0 )
by Brent
03:26
created

SassParser   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A parse() 0 12 2
1
<?php
2
3
namespace Brendt\Stitcher\Parser;
4
5
use Brendt\Stitcher\Config;
6
use Leafo\ScssPhp\Compiler;
7
use Symfony\Component\Finder\Finder;
8
9
/**
10
 * The SassParser take a path to one or more sass files, compiles it to CSS and returns that CSS.
11
 */
12
class SassParser implements Parser {
13
14
    /**
15
     * @param $path
16
     *
17
     * @return string
18
     */
19
    public function parse($path) {
20
        /** @var Compiler $sass */
21
        $sass = Config::getDependency('engine.sass');
22
        $files = Finder::create()->files()->in(Config::get('directories.src'))->path(trim($path, '/'));
23
        $data = '';
24
25
        foreach ($files as $file) {
26
            $data .= $sass->compile($file->getContents());
27
        }
28
29
        return $data;
30
    }
31
32
}
33