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

src/CommandFactory.php (2 issues)

Labels
Severity

Upgrade to new PHP Analysis Engine

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 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
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
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