Completed
Push — master ( e7d764...b7ccb8 )
by ARCANEDEV
09:18
created

RouteServiceProvider::getRouteNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace Arcanedev\LogViewer\Providers;
2
3
use Arcanedev\LogViewer\Http\Routes\LogViewerRoute;
4
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider;
5
use Illuminate\Contracts\Routing\Registrar as Router;
6
7
/**
8
 * Class     RouteServiceProvider
9
 *
10
 * @package  Arcanedev\LogViewer\Providers
11
 * @author   ARCANEDEV <[email protected]>
12
 *
13
 * @codeCoverageIgnore
14
 */
15
class RouteServiceProvider extends ServiceProvider
0 ignored issues
show
Bug introduced by
There is one abstract method getRouteNamespace in this class; you could implement it, or declare this class as abstract.
Loading history...
16
{
17
    /* ------------------------------------------------------------------------------------------------
18
     |  Getters & Setters
19
     | ------------------------------------------------------------------------------------------------
20
     */
21
    /**
22
     * Get Route attributes
23
     *
24
     * @return array
25
     */
26
    public function routeAttributes()
27
    {
28
        return array_merge($this->config('attributes', []), [
29
            'namespace' => 'Arcanedev\\LogViewer\\Http\\Controllers',
30
        ]);
31
    }
32
33
    /**
34
     * Check if routes is enabled
35
     *
36
     * @return bool
37
     */
38
    public function isEnabled()
39
    {
40
        return $this->config('enabled', false);
41
    }
42
43
    /**
44
     * Get config value by key
45
     *
46
     * @param  string      $key
47
     * @param  mixed|null  $default
48
     *
49
     * @return mixed
50
     */
51
    private function config($key, $default = null)
52
    {
53
        /** @var \Illuminate\Config\Repository $config */
54
        $config = $this->app['config'];
55
56
        return $config->get('log-viewer.route.' . $key, $default);
57
    }
58
59
    /* ------------------------------------------------------------------------------------------------
60
     |  Main Functions
61
     | ------------------------------------------------------------------------------------------------
62
     */
63
    /**
64
     * Define the routes for the application.
65
     *
66
     * @param  \Illuminate\Contracts\Routing\Registrar  $router
67
     */
68
    public function map(Router $router)
69
    {
70
        if ($this->isEnabled()) {
71
            $router->group($this->routeAttributes(), function(Router $router) {
72
                LogViewerRoute::register($router);
0 ignored issues
show
Bug introduced by
The method register() does not exist on Arcanedev\LogViewer\Http\Routes\LogViewerRoute. Did you maybe mean registerLogsRoutes()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
73
            });
74
        }
75
    }
76
}
77