Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
GitChanged | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getPreviousFiles | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
getNewFiles | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * Copyright (C) 2018 Kunal Mehta <legoktm@debian.org> |
4 | * |
5 | * This program is free software: you can redistribute it and/or modify |
6 | * it under the terms of the GNU General Public License as published by |
7 | * the Free Software Foundation, either version 3 of the License, or |
8 | * (at your option) any later version. |
9 | * |
10 | * This program is distributed in the hope that it will be useful, |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. |
14 | * |
15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
17 | */ |
18 | |
19 | namespace MediaWiki\Tool\PatchCoverage; |
20 | |
21 | /** |
22 | * Typed object to hold changed files in a |
23 | * git commit |
24 | */ |
25 | class GitChanged { |
26 | /** |
27 | * @var string[] |
28 | */ |
29 | public $added = []; |
30 | |
31 | /** |
32 | * @var string[] |
33 | */ |
34 | public $modified = []; |
35 | |
36 | /** |
37 | * @var string[] |
38 | */ |
39 | public $deleted = []; |
40 | |
41 | /** |
42 | * @var array |
43 | */ |
44 | public $renamed = []; |
45 | |
46 | /** |
47 | * @param array $added |
48 | * @param array $modified |
49 | * @param array $deleted |
50 | * @param array $renamed |
51 | */ |
52 | public function __construct( $added = [], $modified = [], $deleted = [], |
53 | $renamed = [] |
54 | ) { |
55 | $this->added = $added; |
56 | $this->modified = $modified; |
57 | $this->deleted = $deleted; |
58 | $this->renamed = $renamed; |
59 | } |
60 | |
61 | /** |
62 | * @return array|int[]|string[] |
63 | */ |
64 | public function getPreviousFiles() { |
65 | return array_merge( |
66 | $this->deleted, |
67 | $this->modified, |
68 | array_keys( $this->renamed ) |
69 | ); |
70 | } |
71 | |
72 | /** |
73 | * @return array|string[] |
74 | */ |
75 | public function getNewFiles() { |
76 | return array_merge( |
77 | $this->added, |
78 | $this->modified, |
79 | array_values( $this->renamed ) |
80 | ); |
81 | } |
82 | |
83 | } |