Completed
Push — master ( 41ae82...437c90 )
by Dave
13s queued 11s
created

FileMutation::isDeletedFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Static Analysis Results Baseliner (sarb).
5
 *
6
 * (c) Dave Liddament
7
 *
8
 * For the full copyright and licence information please view the LICENSE file distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace DaveLiddament\StaticAnalysisResultsBaseliner\Domain\HistoryAnalyser\UnifiedDiffParser;
14
15
use Webmozart\Assert\Assert;
16
17
class FileMutation
18
{
19
    /**
20
     * @var OriginalFileName|null
21
     */
22
    private $originalFileName;
23
24
    /**
25
     * @var NewFileName|null
26
     */
27
    private $newFileName;
28
29
    /**
30
     * @psalm-var list<LineMutation>
31
     *
32
     * @var LineMutation[]
33
     */
34
    private $lineMutations;
35
36
    /**
37
     * FileMutation constructor.
38
     *
39
     * @psalm-param list<LineMutation> $lineMutations
40
     *
41
     * @param LineMutation[] $lineMutations
42
     */
43
    public function __construct(?OriginalFileName $originalFileName, ?NewFileName $newFileName, array $lineMutations)
44
    {
45
        $oneFileSupplied = (null !== $originalFileName) || (null !== $newFileName);
46
        Assert::true($oneFileSupplied, 'At least 1 originalFileName or newFileName must be supplied');
47
48
        $this->originalFileName = $originalFileName;
49
        $this->newFileName = $newFileName;
50
        $this->lineMutations = $lineMutations;
51
    }
52
53
    public function getOriginalFileName(): OriginalFileName
54
    {
55
        Assert::notNull($this->originalFileName);
56
57
        return $this->originalFileName;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->originalFileName could return the type null which is incompatible with the type-hinted return DaveLiddament\StaticAnal...Parser\OriginalFileName. Consider adding an additional type-check to rule them out.
Loading history...
58
    }
59
60
    public function getNewFileName(): NewFileName
61
    {
62
        Assert::notNull($this->newFileName);
63
64
        return $this->newFileName;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->newFileName could return the type null which is incompatible with the type-hinted return DaveLiddament\StaticAnal...dDiffParser\NewFileName. Consider adding an additional type-check to rule them out.
Loading history...
65
    }
66
67
    /**
68
     * @psalm-return list<LineMutation>
69
     *
70
     * @return LineMutation[]
71
     */
72
    public function getLineMutations(): array
73
    {
74
        return $this->lineMutations;
75
    }
76
77
    public function isAddedFile(): bool
78
    {
79
        return (null === $this->originalFileName) && (null !== $this->newFileName);
80
    }
81
82
    public function isDeletedFile(): bool
83
    {
84
        return (null !== $this->originalFileName) && (null === $this->newFileName);
85
    }
86
}
87