InterfaceCommand   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3
Metric Value
wmc 4
lcom 2
cbo 3
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A configure() 0 8 1
A fire() 0 17 2
1
<?php
2
3
namespace Factory\Console\Make;
4
5
use Factory\Composer;
6
use Factory\Console\BaseCommand;
7
use Factory\Generators\InterfaceGenerator;
8
use Symfony\Component\Console\Input\InputArgument;
9
use Symfony\Component\Console\Input\InputOption;
10
11
class InterfaceCommand extends BaseCommand
12
{
13
    /**
14
     * @var InterfaceGenerator
15
     */
16
    private $generator;
17
    /**
18
     * @var \Factory\Composer
19
     */
20
    private $composer;
21
22
    public function __construct(Composer $composer, InterfaceGenerator $generator)
23
    {
24
        parent::__construct();
25
        $this->generator = $generator;
26
        $this->composer = $composer;
27
    }
28
29
    public function configure()
30
    {
31
        $this->setName('make:interface');
32
        $this->setDescription('Create an interface.');
33
34
        $this->addArgument('name', InputArgument::REQUIRED, 'The name of the class to make.');
35
        $this->addOption('force', null, InputOption::VALUE_NONE, 'The class should overwrite an existing one.');
36
    }
37
38
    public function fire()
39
    {
40
        $data = [
41
            'name' => $this->argument('name'),
42
        ];
43
44
        $result = $this->generator->setData($data)->setForce($this->option('force'))->make();
0 ignored issues
show
Documentation introduced by
$this->option('force') is of type string|array, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45
46
        if ($result)
47
        {
48
            $this->info('Interface: ' . $this->composer->getClassPath($this->argument('name')) . ' created');
49
        }
50
        else
51
        {
52
            $this->error('Something went wrong!');
53
        }
54
    }
55
}
56