Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
DiffCommand
0.00% covered (danger)
0.00%
0 / 16
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 configure
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 8
0.00% covered (danger)
0.00%
0 / 1
6
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
19namespace Wikimedia\CloverDiff;
20
21use Symfony\Component\Console\Command\Command;
22use Symfony\Component\Console\Input\InputArgument;
23use Symfony\Component\Console\Input\InputInterface;
24use Symfony\Component\Console\Output\OutputInterface;
25
26class DiffCommand extends Command {
27    /**
28     * Set up our parameters/arguments
29     */
30    protected function configure(): void {
31        $this->setName( 'diff' )
32            ->addArgument(
33                'first', InputArgument::REQUIRED,
34                'First clover.xml file'
35            )->addArgument(
36                'second', InputArgument::REQUIRED,
37                'Second clover.xml file'
38            );
39    }
40
41    /**
42     * @param InputInterface $input stdin
43     * @param OutputInterface $output stdout
44     *
45     * @return int
46     */
47    protected function execute( InputInterface $input, OutputInterface $output ): int {
48        $differ = new Differ();
49        $diff = $differ->diff(
50            $input->getArgument( 'first' ),
51            $input->getArgument( 'second' )
52        );
53
54        $printer = new DiffPrinter( $output );
55        $lowered = $printer->show( $diff );
56
57        return $lowered ? 1 : 0;
58    }
59}