Completed
Push — master ( d944f0...12d1a2 )
by Jorijn
01:57
created

SecurityCommand::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 9.4285
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
    public function __construct(SecurityChecker $checker)
32
    {
33
        parent::__construct();
34
35
        $this->checker = $checker;
36
    }
37
38
    /**
39
     * Fire the command
40
     */
41
    public function fire()
42
    {
43
        // get the path to composer.lock
44
        $composerLock = base_path('composer.lock');
45
46
        // and feed it into the SecurityChecker
47
        $checkResult = $this->checker->check($composerLock);
48
49
        // then display it using the formatter provided for Symfony
50
        app(SimpleFormatter::class)->displayResults($this->getOutput(), $composerLock, $checkResult);
51
52
        return 0;
53
    }
54
}
55