Installer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 1
dl 0
loc 50
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A stack() 0 6 1
A install() 0 14 3
1
<?php namespace Modules\Core\Console\Installers;
2
3
use Illuminate\Console\Command;
4
use Illuminate\Contracts\Foundation\Application;
5
use Illuminate\Filesystem\Filesystem;
6
use Modules\Core\Services\Composer;
7
8
class Installer
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $scripts = [];
14
15
    /**
16
     * @param Filesystem  $finder
17
     * @param Application $app
18
     * @param Composer    $composer
19
     */
20
    public function __construct(Application $app, Filesystem $finder, Composer $composer)
21
    {
22
        $this->finder = $finder;
0 ignored issues
show
Bug introduced by
The property finder 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...
23
        $this->app = $app;
0 ignored issues
show
Bug introduced by
The property app 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...
24
        $this->composer = $composer;
0 ignored issues
show
Bug introduced by
The property composer 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...
25
    }
26
27
    /**
28
     * @param  array $scripts
29
     * @return $this
30
     */
31
    public function stack(array $scripts)
32
    {
33
        $this->scripts = $scripts;
34
35
        return $this;
36
    }
37
38
    /**
39
     * Fire install scripts
40
     * @param  Command $command
41
     * @return bool
42
     */
43
    public function install(Command $command)
44
    {
45
        foreach ($this->scripts as $script) {
46
            try {
47
                $this->app->make($script)->fire($command);
48
            } catch (\Exception $e) {
49
                $command->error($e->getMessage());
50
51
                return false;
52
            }
53
        }
54
55
        return true;
56
    }
57
}
58