Hashes::execute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 2
eloc 11
nc 2
nop 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