Completed
Pull Request — master (#659)
by Andrey
01:44
created

ApiDocGeneratorServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 23 2
A register() 0 4 1
A bootRoutes() 0 8 2
1
<?php
2
3
namespace Mpociot\ApiDoc;
4
5
use Illuminate\Support\ServiceProvider;
6
use Mpociot\ApiDoc\Commands\GenerateDocumentation;
7
use Mpociot\ApiDoc\Commands\RebuildDocumentation;
8
9
class ApiDocGeneratorServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the application events.
13
     *
14
     * @return void
15
     */
16
    public function boot()
17
    {
18
        $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc');
19
20
        $this->publishes([
21
            __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc',
22
        ], 'apidoc-views');
23
24
        $this->publishes([
25
            __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php',
26
        ], 'apidoc-config');
27
28
        $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc');
29
30
        $this->bootRoutes();
31
32
        if ($this->app->runningInConsole()) {
33
            $this->commands([
34
                GenerateDocumentation::class,
35
                RebuildDocumentation::class,
36
            ]);
37
        }
38
    }
39
40
    /**
41
     * Register the API doc commands.
42
     *
43
     * @return void
44
     */
45
    public function register()
46
    {
47
        //
48
    }
49
50
    protected function bootRoutes()
51
    {
52
        if ($this->app['config']->get('apidoc.type', 'static') == 'laravel') {
53
            $this->loadRoutesFrom(
54
                __DIR__.'/../routes/laravel.php'
55
            );
56
        }
57
    }
58
}
59