Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
81.82% |
9 / 11 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
Differ | |
81.82% |
9 / 11 |
|
0.00% |
0 / 1 |
7.29 | |
0.00% |
0 / 1 |
diff | |
81.82% |
9 / 11 |
|
0.00% |
0 / 1 |
7.29 |
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 Wikimedia\CloverDiff; |
20 | |
21 | /** |
22 | * Diff two files |
23 | */ |
24 | class Differ { |
25 | |
26 | /** |
27 | * @param CloverXml|string|null $old path to old XML file |
28 | * @param CloverXml|string|null $new path to new XML file |
29 | * |
30 | * @return Diff |
31 | */ |
32 | public function diff( $old, $new ): Diff { |
33 | if ( $old && !( $old instanceof CloverXml ) ) { |
34 | $old = new CloverXml( $old ); |
35 | } |
36 | if ( $new && !( $new instanceof CloverXml ) ) { |
37 | $new = new CloverXml( $new ); |
38 | } |
39 | if ( $old ) { |
40 | $oldFiles = $old->getFiles(); |
41 | } else { |
42 | $oldFiles = []; |
43 | } |
44 | if ( $new ) { |
45 | $newFiles = $new->getFiles(); |
46 | } else { |
47 | $newFiles = []; |
48 | } |
49 | |
50 | return new Diff( $oldFiles, $newFiles ); |
51 | } |
52 | |
53 | } |