Passed
Pull Request — master (#10)
by
unknown
15:04
created

SecurityCommand::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 12
ccs 3
cts 3
cp 1
crap 1
rs 9.4285
c 0
b 0
f 0
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
     * The name and signature of the console command.
13
     *
14
     * @var string
15
     */
16
    protected $name = 'security-check:now';
17
18
    /**
19
     * The console command description.
20
     *
21
     * @var string
22
     */
23
    protected $description = 'Checks composer.lock for any vulnerabilities against the SensioLabs checker.';
24
25
    /**
26
     * @var SecurityChecker
27
     */
28
    protected $checker;
29
30
    /**
31 15
     * SecurityCommand constructor.
32
     *
33 15
     * @param SecurityChecker $checker
34
     */
35 15
    public function __construct(SecurityChecker $checker)
36 15
    {
37
        parent::__construct();
38
39
        $this->checker = $checker;
40
    }
41 3
42
    /**
43
     * Execute the console command.
44 3
     */
45
    public function handle()
46
    {
47 3
        // get the path to composer.lock
48
        $composerLock = base_path('composer.lock');
49
50 3
        // and feed it into the SecurityChecker
51
        $checkResult = $this->checker->check($composerLock);
52 3
53
        // then display it using the formatter provided for Symfony
54
        app(SimpleFormatter::class)->displayResults($this->getOutput(), $composerLock, $checkResult);
55
56
        return 0;
57
    }
58
}
59