Code Duplication    Length = 53-53 lines in 2 locations

src/Checks/ComposerWithDevDependenciesIsUpToDate.php 1 location

@@ 9-61 (lines=53) @@
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\Str;
8
9
class ComposerWithDevDependenciesIsUpToDate implements Check
10
{
11
    /** @var Composer */
12
    private $composer;
13
14
    /** @var string */
15
    private $output;
16
17
    public function __construct(Composer $composer)
18
    {
19
        $this->composer = $composer;
20
        $this->composer->setWorkingPath(base_path());
21
    }
22
23
    /**
24
     * The name of the check.
25
     *
26
     * @param array $config
27
     * @return string
28
     */
29
    public function name(array $config): string
30
    {
31
        return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.name');
32
    }
33
34
    /**
35
     * Perform the actual verification of this check.
36
     *
37
     * @param array $config
38
     * @return bool
39
     */
40
    public function check(array $config): bool
41
    {
42
        $additionalOptions = Arr::get($config, 'additional_options', '');
43
44
        $this->output = $this->composer->installDryRun($additionalOptions);
45
46
        return Str::contains($this->output, ['Nothing to install or update', 'Nothing to install, update or remove']);
47
    }
48
49
    /**
50
     * The error message to display in case the check does not pass.
51
     *
52
     * @param array $config
53
     * @return string
54
     */
55
    public function message(array $config): string
56
    {
57
        return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.message', [
58
            'more' => $this->output,
59
        ]);
60
    }
61
}
62

src/Checks/ComposerWithoutDevDependenciesIsUpToDate.php 1 location

@@ 9-61 (lines=53) @@
6
use Illuminate\Support\Arr;
7
use Illuminate\Support\Str;
8
9
class ComposerWithoutDevDependenciesIsUpToDate implements Check
10
{
11
    /** @var Composer */
12
    private $composer;
13
14
    /** @var string */
15
    private $output;
16
17
    public function __construct(Composer $composer)
18
    {
19
        $this->composer = $composer;
20
        $this->composer->setWorkingPath(base_path());
21
    }
22
23
    /**
24
     * The name of the check.
25
     *
26
     * @param array $config
27
     * @return string
28
     */
29
    public function name(array $config): string
30
    {
31
        return trans('self-diagnosis::checks.composer_without_dev_dependencies_is_up_to_date.name');
32
    }
33
34
    /**
35
     * Perform the actual verification of this check.
36
     *
37
     * @param array $config
38
     * @return bool
39
     */
40
    public function check(array $config): bool
41
    {
42
        $additionalOptions = Arr::get($config, 'additional_options', '');
43
44
        $this->output = $this->composer->installDryRun('--no-dev ' . $additionalOptions);
45
46
        return Str::contains($this->output, ['Nothing to install or update', 'Nothing to install, update or remove']);
47
    }
48
49
    /**
50
     * The error message to display in case the check does not pass.
51
     *
52
     * @param array $config
53
     * @return string
54
     */
55
    public function message(array $config): string
56
    {
57
        return trans('self-diagnosis::checks.composer_without_dev_dependencies_is_up_to_date.message', [
58
            'more' => $this->output,
59
        ]);
60
    }
61
}
62