Completed
Push — master ( f2e7a7...9c404b )
by Victor
01:52
created

TextContentParser   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A parse() 0 4 1
A convertContentToLines() 0 9 2
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