Installer::stack()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
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