BootstrapperServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 9

Test Coverage

Coverage 95.83%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 9
dl 0
loc 75
ccs 23
cts 24
cp 0.9583
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 1
B boot() 0 25 3
1
<?php
2
3
/*
4
 * This file is part of Rocketeer
5
 *
6
 * (c) Maxime Fabre <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 */
12
13
namespace Rocketeer\Services\Bootstrapper;
14
15
use ErrorException;
16
use League\Container\ServiceProvider\AbstractServiceProvider;
17
use League\Container\ServiceProvider\BootableServiceProviderInterface;
18
use Rocketeer\Facades\Rocketeer;
19
use Rocketeer\Services\Bootstrapper\Modules\ConfigurationBootstrapper;
20
use Rocketeer\Services\Bootstrapper\Modules\PathsBootstrapper;
21
use Rocketeer\Services\Bootstrapper\Modules\TasksBootstrapper;
22
use Rocketeer\Services\Bootstrapper\Modules\UserBootstrapper;
23
use Rocketeer\Traits\HasLocatorTrait;
24
25
class BootstrapperServiceProvider extends AbstractServiceProvider implements BootableServiceProviderInterface
26
{
27
    use HasLocatorTrait;
28
29
    /**
30
     * @var array
31
     */
32
    protected $provides = [
33
        Bootstrapper::class,
34
        'rocketeer.tasks.check',
35
        'rocketeer.tasks.cleanup',
36
        'rocketeer.tasks.create-release',
37
        'rocketeer.tasks.current',
38
        'rocketeer.tasks.dependencies',
39
        'rocketeer.tasks.deploy',
40
        'rocketeer.tasks.friday-deploy',
41
        'rocketeer.tasks.ignite',
42
        'rocketeer.tasks.installer',
43
        'rocketeer.tasks.migrate',
44
        'rocketeer.tasks.notify',
45
        'rocketeer.tasks.primer',
46
        'rocketeer.tasks.rollback',
47
        'rocketeer.tasks.setup',
48
        'rocketeer.tasks.swap-symlink',
49
        'rocketeer.tasks.teardown',
50
        'rocketeer.tasks.test',
51
        'rocketeer.tasks.update',
52
        'rocketeer.tasks.updater',
53
    ];
54
55
    /**
56
     * {@inheritdoc}
57
     */
58 442
    public function register()
59
    {
60
        $this->container->share(Bootstrapper::class, function () {
61 442
            $bootstrapper = new Bootstrapper($this->container);
62 442
            $bootstrapper->register(new ConfigurationBootstrapper());
63 442
            $bootstrapper->register(new PathsBootstrapper());
64 442
            $bootstrapper->register(new TasksBootstrapper());
65 442
            $bootstrapper->register(new UserBootstrapper());
66
67 442
            return $bootstrapper;
68 442
        });
69 442
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74 442
    public function boot()
75
    {
76 442
        $this->register();
77
78
        // Handle errors as exceptions
79 442
        set_error_handler(function ($level, $message, $file, $line) {
80 9
            if (error_reporting() & $level) {
81
                throw new ErrorException($message, 0, $level, $file, $line);
82
            }
83 442
        });
84
85
        // Set container onto facade and setup alias
86 442
        Rocketeer::setContainer($this->container);
87 442
        if (!class_exists('Rocketeer')) {
88 1
            class_alias(Rocketeer::class, 'Rocketeer');
89 1
        }
90
91
        // Bootstrap Rocketeer
92 442
        $this->bootstrapper->bootstrapPaths();
0 ignored issues
show
Documentation Bug introduced by Maxime FABRE
The method bootstrapPaths does not exist on object<Rocketeer\Service...tstrapper\Bootstrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
93 442
        $this->bootstrapper->bootstrapTasks();
0 ignored issues
show
Documentation Bug introduced by Maxime FABRE
The method bootstrapTasks does not exist on object<Rocketeer\Service...tstrapper\Bootstrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
94 442
        $this->bootstrapper->bootstrapConfiguration();
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method bootstrapConfiguration does not exist on object<Rocketeer\Service...tstrapper\Bootstrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
95
96
        // Load the user's events, tasks, plugins, and configurations
97 442
        $this->bootstrapper->bootstrapUserFiles();
0 ignored issues
show
Documentation Bug introduced by Maxime Fabre
The method bootstrapUserFiles does not exist on object<Rocketeer\Service...tstrapper\Bootstrapper>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
98 442
    }
99
}
100