Completed
Push — develop ( 819fb3...3b8721 )
by Chris
02:50
created

CreateFile::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 12
ccs 0
cts 12
cp 0
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
crap 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 CreateFile extends BaseCommand
18
{
19
    protected function configure()
20
    {
21
        $this
22
            ->setName("createfile")
23
            ->setDescription("Creates the file needed for DVC")
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('<error>Fail!</error>');
40
            $output->writeln('Unable to fetch hashes');
41
42
            return 2;
43
        }
44
45
        $output->writeln('<info>Filename:</info> ' . $hashes['md5'] . '.txt');
46
        $output->writeln('<info>Contents:</info>');
47
        $output->writeln($comodoDecodeCSR->generateDVC());
48
        $output->writeln('<info>URL:</info> http://' . $comodoDecodeCSR->getCN() . '/' . $hashes['md5'] . '.txt');
49
50
        return 0;
51
    }
52
}
53