CharacterServiceProvider   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 1
dl 0
loc 90
ccs 0
cts 58
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 16 4
A boot() 0 3 1
A loadHelpers() 0 6 2
A registerPublishableResources() 0 18 2
A registerConfigs() 0 7 1
A registerConsoleCommands() 0 5 1
A registerAppCommands() 0 3 1
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();
0 ignored issues
show
Unused Code introduced by
The call to the method FreedomCore\TrinityCore\...::registerAppCommands() seems un-needed as the method has no side-effects.

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:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

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:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

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:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
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