Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
81.82% covered (warning)
81.82%
9 / 11
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Differ
81.82% covered (warning)
81.82%
9 / 11
0.00% covered (danger)
0.00%
0 / 1
7.29
0.00% covered (danger)
0.00%
0 / 1
 diff
81.82% covered (warning)
81.82%
9 / 11
0.00% covered (danger)
0.00%
0 / 1
7.29
1<?php
2declare( strict_types = 1 );
3
4/**
5 * Copyright (C) 2018 Kunal Mehta <legoktm@debian.org>
6 * @license GPL-3.0-or-later
7 */
8
9namespace Wikimedia\CloverDiff;
10
11/**
12 * Diff two files
13 */
14class Differ {
15
16    /**
17     * @param CloverXml|string|null $old path to old XML file
18     * @param CloverXml|string|null $new path to new XML file
19     *
20     * @return Diff
21     */
22    public function diff( $old, $new ): Diff {
23        if ( $old && !( $old instanceof CloverXml ) ) {
24            $old = new CloverXml( $old );
25        }
26        if ( $new && !( $new instanceof CloverXml ) ) {
27            $new = new CloverXml( $new );
28        }
29        if ( $old ) {
30            $oldFiles = $old->getFiles();
31        } else {
32            $oldFiles = [];
33        }
34        if ( $new ) {
35            $newFiles = $new->getFiles();
36        } else {
37            $newFiles = [];
38        }
39
40        return new Diff( $oldFiles, $newFiles );
41    }
42
43}