Completed
Pull Request — master (#60)
by
unknown
177:15
created

ComposerWithDevDependenciesIsUpToDate::name()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace BeyondCode\SelfDiagnosis\Checks;
4
5
use BeyondCode\SelfDiagnosis\Composer;
6
7 View Code Duplication
class ComposerWithDevDependenciesIsUpToDate 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...
8
{
9
    /** @var Composer */
10
    private $composer;
11
12
    /** @var string */
13
    private $output;
14
15 20
    public function __construct(Composer $composer)
16
    {
17 20
        $this->composer = $composer;
18 20
        $this->composer->setWorkingPath(base_path());
19 20
    }
20
21
    /**
22
     * The name of the check.
23
     *
24
     * @param array $config
25
     * @return string
26
     */
27 4
    public function name(array $config): string
28
    {
29 4
        return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.name');
30
    }
31
32
    /**
33
     * Perform the actual verification of this check.
34
     *
35
     * @param array $config
36
     * @return bool
37
     */
38 12
    public function check(array $config): bool
39
    {
40 12
        $additionalOptions = array_get($config, 'additional_options', '');
41
42 12
        $this->output = $this->composer->installDryRun($additionalOptions);
43
44 12
        return str_contains($this->output, 'Nothing to install or update');
45
    }
46
47
    /**
48
     * The error message to display in case the check does not pass.
49
     *
50
     * @param array $config
51
     * @return string
52
     */
53 4
    public function message(array $config): string
54
    {
55 4
        return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.message', [
56 4
            'more' => $this->output,
57
        ]);
58
    }
59
}
60