Completed
Push — master ( 0c4fc0...8aea5a )
by Jorijn
11:28
created

SecurityCommand::fire()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 10
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
     * @param SecurityChecker $checker
29
     */
30
    public function __construct(SecurityChecker $checker)
31
    {
32
        parent::__construct();
33
34
        $this->checker = $checker;
35
    }
36
37
    /**
38
     *
39
     */
40
    public function fire()
41
    {
42
        // get the path to composer.lock
43
        $composerLock = base_path('composer.lock');
0 ignored issues
show
Bug introduced by
The function base_path was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $composerLock = /** @scrutinizer ignore-call */ base_path('composer.lock');
Loading history...
44
45
        // and feed it into the SecurityChecker
46
        $checkResult = $this->checker->check($composerLock);
47
48
        // then display it using the formatter provided for Symfony
49
        app(SimpleFormatter::class)->displayResults($this->getOutput(), $composerLock, $checkResult);
0 ignored issues
show
Bug introduced by
The function app was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        /** @scrutinizer ignore-call */ app(SimpleFormatter::class)->displayResults($this->getOutput(), $composerLock, $checkResult);
Loading history...
50
    }
51
}