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

BaseCommand::loadCSR()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
crap 6
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
    public function loadCSR(InputInterface $input, OutputInterface $output)
26
    {
27
        $csrFile = $input->getArgument('csr');
28
        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();
1 ignored issue
show
Coding Style Compatibility introduced by
The method loadCSR() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
33
        }
34
35
        return file_get_contents($csrFile);
36
    }
37
}
38