Completed
Push — master ( 0c0a31...2d5d2b )
by Igor
03:19 queued 02:02
created

PhpBattleriteServiceProvider::serviceProviders()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace guastallaigor\PhpBattlerite\ServiceProviders;
4
5
use Illuminate\Support\ServiceProvider;
6
use guastallaigor\PhpBattlerite\Facades\PhpBattlerite;
7
use guastallaigor\PhpBattlerite\Main;
8
9
 /**
10
  * PHP-Battlerite easy API
11
  *
12
  * @category  Games
13
  * @package   ServiceProviders
14
  * MainServiceProvider class for this package
15
  * @author    Igor Guastalla de Lima  <[email protected]>
16
  * @copyright 2018 PHP Battlerite
17
  * @license   MIT https://github.com/guastallaigor/php-battlerite/blob/master/LICENSE
18
  * @link      https://github.com/guastallaigor/php-battlerite
19
  */
20
class PhpBattleriteServiceProvider extends ServiceProvider
21
{
22
23
    /**
24
     * Indicates if loading of the provider is deferred.
25
     *
26
     * @var bool
27
     */
28
    protected $defer = false;
29
30
    /**
31
     * Boot the package.
32
     *
33
     * @return void
34
     */
35
    public function boot()
36
    {
37
        /*
38
        |--------------------------------------------------------------------------
39
        | Publish the Config file from the Package to the App directory
40
        |--------------------------------------------------------------------------
41
        */
42
        $this->configPublisher();
43
    }
44
45
    /**
46
     * Register the service provider.
47
     *
48
     * @return void
49
     */
50
    public function register()
51
    {
52
        /*
53
        |--------------------------------------------------------------------------
54
        | Implementation Bindings
55
        |--------------------------------------------------------------------------
56
        */
57
        $this->implementationBindings();
58
59
        /*
60
        |--------------------------------------------------------------------------
61
        | Facade Bindings
62
        |--------------------------------------------------------------------------
63
        */
64
        $this->facadeBindings();
65
    }
66
67
    /**
68
     * Binding app to Main class.
69
     *
70
     * @return void
71
     */
72
    private function implementationBindings()
73
    {
74
        $this->app->bind(
75
            Main::class
76
        );
77
    }
78
79
    /**
80
     * Publish the Config file from the Package to the App directory
81
     *
82
     * @return void
83
     */
84
    private function configPublisher()
85
    {
86
        // When users execute Laravel's vendor:publish command, the config file will be copied to the specified location
87
        $this->publishes(
88
            [
89
                __DIR__ . '/Config/phpbattlerite.php' =>
90
                    config_path('phpbattlerite.php')
91
            ]
92
        );
93
    }
94
95
    /**
96
     * Binding app to the Facede.
97
     *
98
     * @return void
99
     */
100
    private function facadeBindings()
101
    {
102
        // Register 'phpbattlerite.say' instance container
103
        $this->app['phpbattlerite.phpbattlerite'] = $this->app->share(
0 ignored issues
show
Bug introduced by
The method share() does not seem to exist on object<Illuminate\Contra...Foundation\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
104
            function ($app) {
105
                return $app->make(Main::class);
106
            }
107
        );
108
109
        // Register 'PhpBattlerite' Alias,
110
        // So users don't have to add the Alias to the 'app/config/app.php'
111
        $this->app->booting(
112
            function () {
113
                $loader = \Illuminate\Foundation\AliasLoader::getInstance();
114
                $loader->alias('PhpBattlerite', PhpBattleriteFacede::class);
115
            }
116
        );
117
    }
118
119
    /**
120
     * Get the services provided by the provider.
121
     *
122
     * @return array
123
     */
124
    public function provides()
125
    {
126
        return [];
127
    }
128
}
129