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

ApiDocGeneratorServiceProvider   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 58
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 26 2
A register() 0 3 1
A bootRoutes() 0 11 3
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
use Mpociot\ApiDoc\Matching\RouteMatcherInterface;
9
10
class ApiDocGeneratorServiceProvider extends ServiceProvider
11
{
12
    /**
13
     * Bootstrap the application events.
14
     *
15
     * @return void
16
     */
17
    public function boot()
18
    {
19
        $this->loadViewsFrom(__DIR__.'/../resources/views/', 'apidoc');
20
21
        $this->publishes([
22
            __DIR__.'/../resources/views' => app()->basePath().'/resources/views/vendor/apidoc',
23
        ], 'apidoc-views');
24
25
        $this->publishes([
26
            __DIR__.'/../config/apidoc.php' => app()->basePath().'/config/apidoc.php',
27
        ], 'apidoc-config');
28
29
        $this->mergeConfigFrom(__DIR__.'/../config/apidoc.php', 'apidoc');
30
31
        $this->bootRoutes();
32
33
        if ($this->app->runningInConsole()) {
34
            $this->commands([
35
                GenerateDocumentation::class,
36
                RebuildDocumentation::class,
37
            ]);
38
        }
39
40
        // Bind the route matcher implementation
41
        $this->app->bind(RouteMatcherInterface::class, $this->app['config']['apidoc']['routeMatcher']);
42
    }
43
44
    /**
45
     * Register the API doc commands.
46
     *
47
     * @return void
48
     */
49
    public function register()
50
    {
51
    }
52
53
    /**
54
     * Initializing routes in the application.
55
     */
56
    protected function bootRoutes()
57
    {
58
        if (
59
            config('apidoc.type', 'static') === 'laravel' &&
60
            config('apidoc.laravel.autoload', false)
61
        ) {
62
            $this->loadRoutesFrom(
63
                __DIR__.'/../routes/laravel.php'
64
            );
65
        }
66
    }
67
}
68