Completed
Push — master ( 1f380c...d7ed2e )
by Victor
01:47
created

TextContentParser::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: victor
5
 * Date: 09/04/16
6
 */
7
8
namespace LazyEight\DiTesto\Parser;
9
10
11
use LazyEight\DiTesto\ValueObject\AbstractFileContent;
12
use LazyEight\DiTesto\ValueObject\TextFile\Line;
13
use LazyEight\DiTesto\ValueObject\TextFile\TextContent;
14
15
class TextContentParser
16
{
17
    /**
18
     * @var AbstractFileContent
19
     */
20
    private $content;
21
22
    /**
23
     * @param AbstractFileContent $content
24
     */
25 1
    public function __construct(AbstractFileContent $content)
26
    {
27 1
        $this->content = $content;
28 1
    }
29
30
    /**
31
     * @return TextContent
32
     */
33 1
    public function parse()
34
    {
35 1
        return new TextContent($this->content->getValue(), $this->convertContentToLines());
36
    }
37
38
    /**
39
     * @return array
40
     */
41 1
    protected function convertContentToLines()
42
    {
43 1
        $lines = array();
44 1
        $arrLines = $this->content->getValue()->split('\n');
45 1
        foreach ($arrLines as $value) {
46 1
            $lines[] = new Line($value);
47 1
        }
48 1
        return $lines;
49
    }
50
}
51