InteractsWithApplication::bind()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 3
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\Support\Providers\Concerns;
6
7
/**
8
 * Trait     InteractsWithApplication
9
 *
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
trait InteractsWithApplication
13
{
14
    /* -----------------------------------------------------------------
15
     |  Main Methods
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Register multiple service providers.
21
     *
22
     * @param  array  $providers
23
     */
24
    protected function registerProviders(array $providers)
25
    {
26
        foreach ($providers as $provider) {
27
            $this->registerProvider($provider);
28
        }
29
    }
30
31
    /**
32
     * Register a service provider.
33
     *
34
     * @param  \Illuminate\Support\ServiceProvider|string  $provider
35
     * @param  bool                                        $force
36
     *
37
     * @return \Illuminate\Support\ServiceProvider
38
     */
39
    protected function registerProvider($provider, $force = false)
40
    {
41
        return $this->app->register($provider, $force);
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...
42
    }
43
44
    /**
45
     * Register a console service provider.
46
     *
47
     * @param  \Illuminate\Support\ServiceProvider|string  $provider
48
     * @param  bool                                        $force
49
     *
50
     * @return \Illuminate\Support\ServiceProvider|null
51
     */
52
    protected function registerConsoleServiceProvider($provider, $force = false)
53
    {
54
        if ($this->app->runningInConsole()) {
55
            return $this->registerProvider($provider, $force);
56
        }
57
58
        return null;
59
    }
60
61
    /**
62
     * Register the package's custom Artisan commands when running in console.
63
     *
64
     * @param  array  $commands
65
     */
66
    protected function registerCommands(array $commands)
67
    {
68
        if ($this->app->runningInConsole()) {
69
            $this->commands($commands);
0 ignored issues
show
Bug introduced by
The method commands() does not exist on Arcanedev\Support\Provid...nteractsWithApplication. Did you maybe mean registerCommands()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
70
        }
71
    }
72
73
    /**
74
     * Register a binding with the container.
75
     *
76
     * @param  string                $abstract
77
     * @param  \Closure|string|null  $concrete
78
     * @param  bool                  $shared
79
     */
80
    protected function bind($abstract, $concrete = null, $shared = false)
81
    {
82
        $this->app->bind($abstract, $concrete, $shared);
83
    }
84
85
    /**
86
     * Register a shared binding in the container.
87
     *
88
     * @param  string|array          $abstract
89
     * @param  \Closure|string|null  $concrete
90
     */
91
    protected function singleton($abstract, $concrete = null)
92
    {
93
        $this->app->singleton($abstract, $concrete);
94
    }
95
}
96