1
|
|
|
<?php namespace FreedomCore\TrinityCore\Character; |
2
|
|
|
|
3
|
|
|
use Illuminate\Foundation\AliasLoader; |
4
|
|
|
use Illuminate\Support\ServiceProvider; |
5
|
|
|
use \FreedomCore\TrinityCore\Character\Facades\Character as CharacterFacade; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Class CharacterServiceProvider |
9
|
|
|
* @package FreedomCore\TrinityCore\Character |
10
|
|
|
*/ |
11
|
|
|
class CharacterServiceProvider extends ServiceProvider |
12
|
|
|
{ |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Register Service Provider |
16
|
|
|
*/ |
17
|
|
|
public function register() |
18
|
|
|
{ |
19
|
|
|
(AliasLoader::getInstance())->alias('Character', CharacterFacade::class); |
20
|
|
|
$this->app->singleton('character', function () { |
21
|
|
|
return new Character(); |
22
|
|
|
}); |
23
|
|
|
$this->loadHelpers(); |
24
|
|
|
$this->registerConfigs(); |
25
|
|
|
if ($this->app->runningInConsole()) { |
26
|
|
|
$this->registerPublishableResources(); |
27
|
|
|
$this->registerConsoleCommands(); |
28
|
|
|
} |
29
|
|
|
if (!$this->app->runningInConsole() || config('app.env') == 'testing') { |
30
|
|
|
$this->registerAppCommands(); |
|
|
|
|
31
|
|
|
} |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* Bootstrap the application events. |
36
|
|
|
* @return void |
37
|
|
|
*/ |
38
|
|
|
public function boot() |
39
|
|
|
{ |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Load helpers. |
44
|
|
|
*/ |
45
|
|
|
protected function loadHelpers() |
46
|
|
|
{ |
47
|
|
|
foreach (glob(__DIR__.'/Helpers/*.php') as $filename) { |
48
|
|
|
require_once $filename; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Register the publishable files. |
54
|
|
|
*/ |
55
|
|
|
private function registerPublishableResources() |
56
|
|
|
{ |
57
|
|
|
$publishablePath = dirname(__DIR__) . '/publishable'; |
58
|
|
|
$publishable = [ |
59
|
|
|
'migrations' => [ |
60
|
|
|
"{$publishablePath}/database/migrations/" => database_path('migrations'), |
61
|
|
|
], |
62
|
|
|
'seeds' => [ |
63
|
|
|
"{$publishablePath}/database/seeds/" => database_path('seeds'), |
64
|
|
|
], |
65
|
|
|
'config' => [ |
66
|
|
|
"{$publishablePath}/config/character.php" => config_path('character.php'), |
67
|
|
|
] |
68
|
|
|
]; |
69
|
|
|
foreach ($publishable as $group => $paths) { |
70
|
|
|
$this->publishes($paths, $group); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* Register Configuration Files |
76
|
|
|
*/ |
77
|
|
|
public function registerConfigs() |
78
|
|
|
{ |
79
|
|
|
$this->mergeConfigFrom( |
80
|
|
|
dirname(__DIR__) . '/publishable/config/character.php', |
81
|
|
|
'character' |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Register the commands accessible from the Console. |
87
|
|
|
*/ |
88
|
|
|
private function registerConsoleCommands() |
89
|
|
|
{ |
90
|
|
|
$this->commands(Commands\InstallCommand::class); |
91
|
|
|
$this->commands(Commands\LoadGearSets::class); |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
/** |
95
|
|
|
* Register the commands accessible from the App. |
96
|
|
|
*/ |
97
|
|
|
private function registerAppCommands() |
98
|
|
|
{ |
99
|
|
|
} |
100
|
|
|
} |
101
|
|
|
|
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: