Completed
Push — master ( 751a3d...b7ca33 )
by Sebastian
17:18 queued 15:56
created

File::getChanges()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Git.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\Git\Diff;
11
12
/**
13
 * Class File
14
 *
15
 * @package SebastianFeldmann\Git
16
 * @author  Sebastian Feldmann <[email protected]>
17
 * @link    https://github.com/sebastianfeldmann/git
18
 * @since   Class available since Release 1.2.0
19
 */
20
class File
21
{
22
    const OP_DELETED  = 'deleted';
23
    const OP_CREATED  = 'created';
24
    const OP_MODIFIED = 'modified';
25
    const OP_RENAMED  = 'renamed';
26
    const OP_COPIED   = 'copied';
27
28
    /**
29
     * List of changes.
30
     *
31
     * @var \SebastianFeldmann\Git\Diff\Change[]
32
     */
33
    private $changes = [];
34
35
    /**
36
     * Filename
37
     *
38
     * @var string
39
     */
40
    private $name;
41
42
    /**
43
     * Operation performed on the file.
44
     *
45
     * @var string
46
     */
47
    private $operation;
48
49
    /**
50
     * File constructor.
51
     *
52
     * @param string $name
53
     * @param string $operation
54
     */
55 12
    public function __construct(string $name, string $operation)
56
    {
57 12
        $this->operation = $operation;
58 12
        $this->name      = $name;
59 12
    }
60
61
    /**
62
     * Returns the filename.
63
     *
64
     * @return string
65
     */
66 1
    public function getName(): string
67
    {
68 1
        return $this->name;
69
    }
70
71
    /**
72
     * Returns the performed operation.
73
     *
74
     * @return string
75
     */
76 8
    public function getOperation(): string
77
    {
78 8
        return $this->operation;
79
    }
80
81
    /**
82
     * Returns the list of changes in this file.
83
     *
84
     * @return \SebastianFeldmann\Git\Diff\Change[]
85
     */
86 10
    public function getChanges(): array
87
    {
88 10
        return $this->changes;
89
    }
90
91
    /**
92
     * Add a change to the list of changes.
93
     *
94
     * @param \SebastianFeldmann\Git\Diff\Change $change
95
     */
96 9
    public function addChange(Change $change)
97
    {
98 9
        $this->changes[] = $change;
99 9
    }
100
}
101