Test Failed
Push — master ( 22b809...326de4 )
by Brent
05:15 queued 39s
created

MarkdownVariable   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 31
ccs 0
cts 12
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A make() 0 6 1
A parse() 0 12 2
1
<?php
2
3
namespace Stitcher\Variable;
4
5
use Pageon\Lib\Markdown\MarkdownParser;
6
use Stitcher\Exception\InvalidConfiguration;
7
use Stitcher\File;
8
9
class MarkdownVariable extends AbstractVariable
10
{
11
    private $parser;
12
13
    public function __construct(string $unparsed, MarkdownParser $parser)
14
    {
15
        parent::__construct($unparsed);
16
17
        $this->parser = $parser;
18
    }
19
20
    public static function make(
21
        string $value,
22
        MarkdownParser $parser
23
    ): MarkdownVariable {
24
        return new self($value, $parser);
25
    }
26
27
    public function parse(): AbstractVariable
28
    {
29
        $contents = File::read($this->unparsed);
30
31
        if (! $contents) {
32
            throw InvalidConfiguration::fileNotFound($this->unparsed);
33
        }
34
35
        $this->parsed = $this->parser->parse($contents);
36
37
        return $this;
38
    }
39
}
40