Test Failed
Push — master ( 819fb3...4760ed )
by Chris
14:15 queued 07:18
created

Hashes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 4
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 12 1
A execute() 0 18 2
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
17
class Hashes extends BaseCommand
18
{
19
    protected function configure()
20
    {
21
        $this
22
            ->setName("hashes")
23
            ->setDescription("Get hashes from a CSR file")
24
            ->addArgument(
25
                'csr',
26
                InputArgument::REQUIRED,
27
                'Location of csr file'
28
            )
29
        ;
30
    }
31
32
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34
        $comodoDecodeCSR = new ComodoDecodeCSR();
35
        $comodoDecodeCSR->setCSR($this->loadCSR($input, $output));
36
        $hashes = $comodoDecodeCSR->fetchHashes();
37
38
        if ($hashes) {
39
            $output->writeln('<info>MD5</info> ' . $hashes['md5']);
40
            $output->writeln('<info>SHA1</info> ' . $hashes['sha1']);
41
42
            return 0;
43
        }
44
45
        $output->writeln('<error>Fail!</error>');
46
        $output->writeln('Unable to fetch hashes');
47
48
        return 2;
49
    }
50
}
51