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

BaseCommand::loadCSR()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.3149

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 4
cts 7
cp 0.5714
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 2.3149
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 Xigen\Application;
13
use Symfony\Component\Console\Input\InputInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Symfony\Component\Console\Command\Command;
16
17
abstract class BaseCommand extends Command
18
{
19
    /**
20
     * Load a .csr file via an CLI argument
21
     * @param  Symfony\Component\Console\Input\InputInterface $input
22
     * @param  Symfony\Component\Console\Output\OutputInterface $output
23
     * @return bool|void
24
     */
25 5
    public function loadCSR(InputInterface $input, OutputInterface $output)
26
    {
27 5
        $csrFile = $input->getArgument('csr');
28 5
        if (!file_exists($csrFile)) {
29
            $output->writeln('<error>Unable to load '. $csrFile .'</error>');
30
            $output->writeln('<error>Please check the path and try again</error>');
31
32
            exit();
33
        }
34
35 5
        return file_get_contents($csrFile);
36
    }
37
}
38