Completed
Push — master ( dbe031...1e3a1a )
by Marcel
01:42
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 5
Ratio 100 %

Importance

Changes 0
Metric Value
dl 5
loc 5
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis\Checks;
4
5
use BeyondCode\SelfDiagnosis\Composer;
6
use BeyondCode\SelfDiagnosis\Checks\Check;
7
8 View Code Duplication
class ComposerWithoutDevDependenciesIsUpToDate implements Check
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    /** @var Composer */
11
    private $composer;
12
13
    /** @var string */
14
    private $output;
15
16
    public function __construct(Composer $composer)
17
    {
18
        $this->composer = $composer;
19
        $this->composer->setWorkingPath(base_path());
20
    }
21
22
    /**
23
     * The name of the check.
24
     *
25
     * @return string
26
     */
27
    public function name(array $config): string
28
    {
29
        return 'Composer dependencies (without dev) are up to date with the composer.lock file.';
30
    }
31
32
    /**
33
     * Perform the actual verification of this check.
34
     *
35
     * @return bool
36
     */
37
    public function check(array $config): bool
38
    {
39
        $this->output = $this->composer->installDryRun('--no-dev');
40
41
        return str_contains($this->output, 'Nothing to install or update');
42
    }
43
44
    /**
45
     * The error message to display in case the check does not pass.
46
     *
47
     * @return string
48
     */
49
    public function message(array $config): string
50
    {
51
        return 'Your composer dependencies are not up to date. Call "composer install".' . $this->output;
52
    }
53
}
54