These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace BeyondCode\SelfDiagnosis\Checks; |
||
4 | |||
5 | use BeyondCode\SelfDiagnosis\Composer; |
||
6 | use Illuminate\Support\Arr; |
||
7 | |||
8 | View Code Duplication | class ComposerWithDevDependenciesIsUpToDate implements Check |
|
0 ignored issues
–
show
|
|||
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 | * @param array $config |
||
26 | * @return string |
||
27 | */ |
||
28 | public function name(array $config): string |
||
29 | { |
||
30 | return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.name'); |
||
31 | } |
||
32 | |||
33 | /** |
||
34 | * Perform the actual verification of this check. |
||
35 | * |
||
36 | * @param array $config |
||
37 | * @return bool |
||
38 | */ |
||
39 | public function check(array $config): bool |
||
40 | { |
||
41 | $additionalOptions = Arr::get($config, 'additional_options', ''); |
||
42 | |||
43 | $this->output = $this->composer->installDryRun($additionalOptions); |
||
44 | |||
45 | return str_contains($this->output, 'Nothing to install or update'); |
||
0 ignored issues
–
show
The function
str_contains() has been deprecated with message: Str::contains() should be used directly instead. Will be removed in Laravel 5.9.
This function has been deprecated. The supplier of the file has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.
Loading history...
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * The error message to display in case the check does not pass. |
||
50 | * |
||
51 | * @param array $config |
||
52 | * @return string |
||
53 | */ |
||
54 | public function message(array $config): string |
||
55 | { |
||
56 | return trans('self-diagnosis::checks.composer_with_dev_dependencies_is_up_to_date.message', [ |
||
57 | 'more' => $this->output, |
||
58 | ]); |
||
59 | } |
||
60 | } |
||
61 |
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.