Completed
Push — master ( b1e025...a9dc14 )
by Jorijn
01:54
created

SecurityCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Jorijn\LaravelSecurityChecker\Console;
4
5
use Illuminate\Console\Command;
6
use SensioLabs\Security\Formatters\SimpleFormatter;
7
use SensioLabs\Security\SecurityChecker;
8
9
class SecurityCommand extends Command
10
{
11
    /**
12
     * @var string
13
     */
14
    protected $name = 'security-check:now';
15
16
    /**
17
     * @var string
18
     */
19
    protected $description = 'Checks composer.lock for any vulnerabilities against the SensioLabs checker.';
20
21
    /**
22
     * @var SecurityChecker
23
     */
24
    protected $checker;
25
26
    /**
27
     * SecurityCommand constructor.
28
     *
29
     * @param SecurityChecker $checker
30
     */
31 15
    public function __construct(SecurityChecker $checker)
32
    {
33 15
        parent::__construct();
34
35 15
        $this->checker = $checker;
36 15
    }
37
38
    /**
39
     * Fire the command
40
     */
41 3
    public function fire()
42
    {
43
        // get the path to composer.lock
44 3
        $composerLock = base_path('composer.lock');
45
46
        // and feed it into the SecurityChecker
47 3
        $checkResult = $this->checker->check($composerLock);
48
49
        // then display it using the formatter provided for Symfony
50 3
        app(SimpleFormatter::class)->displayResults($this->getOutput(), $composerLock, $checkResult);
51
52 3
        return 0;
53
    }
54
}
55