Completed
Push — master ( 875b1a...deeeda )
by Christian
03:55
created

VersionFilePrinter::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace N98\Util\Markdown;
4
5
class VersionFilePrinter
6
{
7
    /**
8
     * @var string
9
     */
10
    private $content;
11
12
    /**
13
     * @param string $content
14
     */
15
    public function __construct($content)
16
    {
17
        $this->content = $content;
18
    }
19
20
    /**
21
     * @param string $startVersion
22
     * @return string
23
     */
24
    public function printFromVersion($startVersion)
25
    {
26
        $contentToReturn = '';
27
28
        $lines = preg_split("/((\r?\n)|(\r\n?))/", $this->content);
29
30
        foreach ($lines as $line) {
31
            if ($line === $startVersion) {
32
                break;
33
            }
34
35
            $contentToReturn .= $line . "\n";
36
        }
37
38
        return trim($contentToReturn) . "\n";
39
    }
40
}
41