Completed
Push — master ( 8bc203...e5859f )
by recca
09:43
created

CommandFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 23
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A create() 0 11 1
1
<?php
2
3
namespace Recca0120\Generator;
4
5
use Recca0120\Generator\Console\GeneratorCommand;
6
7
class CommandFactory
8
{
9
    private $app;
10
11
    public function __construct($config, Generator $generator, $app)
12
    {
13
        $this->config = $config;
0 ignored issues
show
Bug introduced by
The property config does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
14
        $this->generator = $generator;
0 ignored issues
show
Bug introduced by
The property generator does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
        $this->app = $app;
16
    }
17
18
    public function create()
19
    {
20
        return array_map(function ($name) {
21
            $command = new GeneratorCommand($this->generator, $name);
22
23
            $instanceName = 'generator.'.$name;
24
            $this->app->instance($instanceName, $command);
25
26
            return $instanceName;
27
        }, array_keys($this->config));
28
    }
29
}
30