Completed
Push — master ( 19af7f...765e83 )
by ARCANEDEV
14s queued 11s
created

RouteServiceProvider::routeAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 6
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php namespace Arcanedev\LogViewer\Providers;
2
3
use Arcanedev\LogViewer\Http\Routes\LogViewerRoute;
4
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider;
5
6
/**
7
 * Class     RouteServiceProvider
8
 *
9
 * @package  Arcanedev\LogViewer\Providers
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class RouteServiceProvider extends ServiceProvider
13
{
14
    /* -----------------------------------------------------------------
15
     |  Getters & Setters
16
     | -----------------------------------------------------------------
17
     */
18
19
    /**
20
     * Get Route attributes
21
     *
22
     * @return array
23
     */
24
    public function routeAttributes()
25
    {
26
        return array_merge($this->config('attributes', []), [
27
            'namespace' => 'Arcanedev\\LogViewer\\Http\\Controllers',
28
        ]);
29
    }
30
31
    /**
32
     * Check if routes is enabled
33
     *
34
     * @return bool
35
     */
36 888
    public function isEnabled()
37
    {
38 888
        return $this->config('enabled', false);
39
    }
40
41
    /* -----------------------------------------------------------------
42
     |  Main Methods
43
     | -----------------------------------------------------------------
44
     */
45
46
    /**
47
     * Define the routes for the application.
48
     */
49 888
    public function map(): void
50
    {
51 888
        if ($this->isEnabled()) {
52 888
            static::mapRouteClasses([
0 ignored issues
show
Documentation introduced by
array(\Arcanedev\LogView...\LogViewerRoute::class) is of type array<integer,?>, but the function expects a object<Arcanedev\Support...ting\Concerns\iterable>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
53 888
                LogViewerRoute::class,
54
            ]);
55
        }
56 888
    }
57
58
    /* -----------------------------------------------------------------
59
     |  Other Methods
60
     | -----------------------------------------------------------------
61
     */
62
63
    /**
64
     * Get config value by key
65
     *
66
     * @param  string      $key
67
     * @param  mixed|null  $default
68
     *
69
     * @return mixed
70
     */
71 888
    private function config($key, $default = null)
72
    {
73 888
        return $this->app['config']->get("log-viewer.route.$key", $default);
74
    }
75
}
76