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

VersionFilePrinter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 36
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A printFromVersion() 0 16 3
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