Completed
Push — master ( 5ebcb8...b1e025 )
by Jorijn
12s
created

SecurityCommand   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
c 2
b 1
f 0
dl 0
loc 44
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A fire() 0 12 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