Completed
Push — master ( cb32ca...f4aa28 )
by ARCANEDEV
25s
created

ServiceProvider::bind()   A

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 namespace Arcanedev\Support\Providers;
2
3
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
4
5
/**
6
 * Class     ServiceProvider
7
 *
8
 * @package  Arcanedev\Support\Providers
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
abstract class ServiceProvider extends IlluminateServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Main Methods
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Register a service provider.
20
     *
21
     * @param  \Illuminate\Support\ServiceProvider|string  $provider
22
     * @param  bool                                        $force
23
     *
24
     * @return \Illuminate\Support\ServiceProvider
25
     */
26
    protected function registerProvider($provider, $force = false)
27
    {
28
        return $this->app->register($provider, $force);
29
    }
30
31
    /**
32
     * Register multiple service providers.
33
     *
34
     * @param  array  $providers
35
     */
36
    protected function registerProviders(array $providers)
37
    {
38
        foreach ($providers as $provider) {
39
            $this->registerProvider($provider);
40
        }
41
    }
42
43
    /**
44
     * Register a console service provider.
45
     *
46
     * @param  \Illuminate\Support\ServiceProvider|string  $provider
47
     * @param  bool                                        $force
48
     *
49
     * @return \Illuminate\Support\ServiceProvider|null
50
     */
51
    protected function registerConsoleServiceProvider($provider, $force = false)
52
    {
53
        if ($this->app->runningInConsole())
54
            return $this->registerProvider($provider, $force);
55
56
        return null;
57
    }
58
59
    /**
60
     * Register commands service provider.
61
     *
62
     * @param  \Illuminate\Support\ServiceProvider|string  $provider
63
     */
64
    protected function registerCommands($provider)
65
    {
66
        if ($this->app->runningInConsole())
67
            $this->app->register($provider);
68
    }
69
70
    /**
71
     * Register a binding with the container.
72
     *
73
     * @param  string                $abstract
74
     * @param  \Closure|string|null  $concrete
75
     * @param  bool                  $shared
76
     */
77
    public function bind($abstract, $concrete = null, $shared = false)
78
    {
79
        $this->app->bind($abstract, $concrete, $shared);
80
    }
81
82
    /**
83
     * Register a shared binding in the container.
84
     *
85
     * @param  string|array          $abstract
86
     * @param  \Closure|string|null  $concrete
87
     */
88
    protected function singleton($abstract, $concrete = null)
89
    {
90
        $this->app->singleton($abstract, $concrete);
0 ignored issues
show
Bug introduced by
It seems like $abstract defined by parameter $abstract on line 88 can also be of type array; however, Illuminate\Contracts\Con...\Container::singleton() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
91
    }
92
}
93