Completed
Push — develop ( 4146c2...e30e33 )
by Chris
35:42
created

Check   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 90.91%

Importance

Changes 6
Bugs 1 Features 2
Metric Value
wmc 4
c 6
b 1
f 2
lcom 0
cbo 4
dl 0
loc 40
ccs 20
cts 22
cp 0.9091
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
B execute() 0 24 3
1
<?php
2
/**
3
 * @author     Chris Hilsdon <[email protected]>
4
 * @package    ComodoDecodeCSR
5
 * @copyright  2016 Xigen
6
 * @license    GNU General Public License v3
7
 * @link       https://github.com/XigenChris/ComodoDecodeCSR
8
 */
9
10
namespace Xigen\Console;
11
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Input\InputArgument;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Xigen\ComodoDecodeCSR;
16
use Xigen\Exception;
17
18
class Check extends BaseCommand
19
{
20 4
    protected function configure()
21
    {
22 4
        $this
23 4
            ->setName("check")
24 4
            ->setDescription("Check if a domain will pass the DVC")
25 4
            ->addArgument(
26 4
                'csr',
27 4
                InputArgument::REQUIRED,
28
                'Location of csr file for this domain'
29 4
            )
30
        ;
31 4
    }
32
33 3
    protected function execute(InputInterface $input, OutputInterface $output)
34
    {
35 3
        $comodoDecodeCSR = new ComodoDecodeCSR();
36
37
        try {
38 3
            $comodoDecodeCSR->setCSR($this->loadCSR($input, $output));
39 1
            $comodoDecodeCSR->fetchHashes();
40 3
        } catch (Exception $e) {
41 2
            $output->writeln('<error>Error!</error>');
42 2
            $output->writeln('Invalid CSR');
43
44 2
            return 3;
45
        }
46
47 1
        if ($comodoDecodeCSR->checkInstalled()) {
48 1
            $output->writeln('<info>Success!</info> This domain should pass DVC');
49
50 1
            return 0;
51
        }
52
53
        $output->writeln('<error>Fail!</error> There is something wrong with the validation file');
54
55
        return 2;
56
    }
57
}
58