Passed
Push — master ( c1490b...95dfbb )
by Anthony
02:45
created

ChangePackageVersionCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
c 1
b 0
f 0
dl 0
loc 32
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A execute() 0 17 2
A configure() 0 9 1
1
<?php
2
3
namespace PiouPiou\RibsAdminBundle\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputInterface;
8
use Symfony\Component\Console\Output\OutputInterface;
9
use Symfony\Component\Process\Exception\ProcessFailedException;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Proces...\ProcessFailedException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use Symfony\Component\Process\Process;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Process\Process was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
class ChangePackageVersionCommand extends Command
13
{
14
    protected function configure()
15
    {
16
        $this
17
            ->setName('ribsadmin:change-package-version')
18
            ->setDescription('Change a package version')
19
            ->addArgument(
20
                'package-name',
21
                InputArgument::REQUIRED,
22
                'Name of composer package to import with version (example : piou/piou/test-bundle:1.0.0)'
23
            )
24
        ;
25
    }
26
27
    protected function execute(InputInterface $input, OutputInterface $output)
28
    {
29
        $pacakge_name = $input->getArgument('package-name');
30
        $output->writeln("Start composer require " . $pacakge_name);
0 ignored issues
show
Bug introduced by
Are you sure $pacakge_name of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

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

30
        $output->writeln("Start composer require " . /** @scrutinizer ignore-type */ $pacakge_name);
Loading history...
31
32
        $process = new Process("composer require " . $pacakge_name);
33
        $process->run(function ($type, $buffer) {
34
            echo $buffer;
35
        });
36
37
        if (!$process->isSuccessful()) {
38
            throw new ProcessFailedException($process);
39
        }
40
41
        $output->writeln("Change version of " . $pacakge_name . " is finished.");
42
43
        return 0;
44
    }
45
}
46