ServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 6
c 5
b 1
f 0
lcom 1
cbo 1
dl 0
loc 64
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 1
A register() 0 6 1
A config() 0 8 1
A loadRoutes() 0 7 2
A loadViews() 0 10 1
1
<?php
2
3
namespace Taskforcedev\CrudApi;
4
5
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
6
7
/**
8
 * Class ServiceProvider.
9
 *
10
 * @version 1.0.0
11
 */
12
class ServiceProvider extends IlluminateServiceProvider
13
{
14
    /**
15
     * Boot method.
16
     * Loads routes and configuration.
17
     */
18
    public function boot()
19
    {
20
        /* Load our routes */
21
        $this->loadRoutes();
22
        /* Load views */
23
        $this->loadViews();
24
        /* Register config file */
25
        $this->config();
26
    }
27
28
    /**
29
     * Registers the configuration.
30
     */
31
    public function register()
32
    {
33
        $this->mergeConfigFrom(
34
            __DIR__.'/../config/crudapi.php', 'crudapi'
35
        );
36
    }
37
38
    /**
39
     * Allows configuration to be publishable, this allows user to override
40
     * values without editing package.
41
     */
42
    protected function config()
43
    {
44
        $this->publishes(
45
            [
46
                __DIR__.'/../config/crudapi.php' => config_path('crudapi.php'),
47
            ], 'crudapi-config'
48
        );
49
    }
50
51
    /**
52
     * Load the package routes (if the file exists).
53
     */
54
    protected function loadRoutes()
55
    {
56
        $routes_path = __DIR__.'/Http/routes.php';
57
        if (file_exists($routes_path)) {
58
            include __DIR__.'/Http/routes.php';
59
        }
60
    }
61
62
    /**
63
     * Load the packages views.
64
     */
65
    protected function loadViews()
66
    {
67
        $view_path = __DIR__.'/../resources/views';
68
        $this->loadViewsFrom($view_path, 'crudapi');
69
        $this->publishes(
70
            [
71
                $view_path => base_path('resources/views/Taskforcedev/crudapi'),
72
            ], 'crudapi-views'
73
        );
74
    }
75
}
76