TodoComment::file()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace IntegerNet\TodoReminder;
4
5
class TodoComment
6
{
7
    /**
8
     * @var string
9
     */
10
    private $file;
11
    /**
12
     * @var int
13
     */
14
    private $lineNumber;
15
    /**
16
     * @var string
17
     */
18
    private $comment;
19
    /**
20
     * @var int
21
     */
22
    private $notDoneSince;
23
24 15
    public function __construct(string $file, int $lineNumber, string $comment, int $notDoneSince)
25
    {
26 15
        $this->file = $file;
27 15
        $this->lineNumber = $lineNumber;
28 15
        $this->comment = $comment;
29 15
        $this->notDoneSince = $notDoneSince;
30 15
    }
31
32
    public function isInSameFile(TodoComment $other): bool
33
    {
34
        return $other->file === $this->file;
35
    }
36
37
    public function file(): string
38
    {
39
        return $this->file;
40
    }
41
42
    public function formatText(): string
43
    {
44
        $commits = $this->notDoneSince === 1 ? 'commit' : 'commits';
45
        return "Line $this->lineNumber:
46
47
$this->comment
48
49
(NOT DONE since $this->notDoneSince $commits on that file)
50
51
";
52
    }
53
}
54