Completed
Push — master ( 46643f...f8548b )
by ARCANEDEV
20s queued 14s
created

RouteServiceProvider::map()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\LogViewer\Providers;
6
7
use Arcanedev\LogViewer\Http\Routes\LogViewerRoute;
8
use Arcanedev\Support\Providers\RouteServiceProvider as ServiceProvider;
9
10
/**
11
 * Class     RouteServiceProvider
12
 *
13
 * @author   ARCANEDEV <[email protected]>
14
 */
15
class RouteServiceProvider extends ServiceProvider
16
{
17
    /* -----------------------------------------------------------------
18
     |  Getters & Setters
19
     | -----------------------------------------------------------------
20
     */
21
22
    /**
23
     * Check if routes is enabled
24
     *
25
     * @return bool
26
     */
27 596
    public function isEnabled(): bool
28
    {
29 596
        return (bool) $this->config('enabled', false);
30
    }
31
32
    /* -----------------------------------------------------------------
33
     |  Main Methods
34
     | -----------------------------------------------------------------
35
     */
36
37
    /**
38
     * Boot the service provider.
39
     */
40 596
    public function boot(): void
41
    {
42 596
        if ($this->isEnabled()) {
43 596
            $this->routes(function () {
44 298
                static::mapRouteClasses([LogViewerRoute::class]);
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...
45 596
            });
46
        }
47 596
    }
48
49
    /* -----------------------------------------------------------------
50
     |  Other Methods
51
     | -----------------------------------------------------------------
52
     */
53
54
    /**
55
     * Get config value by key
56
     *
57
     * @param  string      $key
58
     * @param  mixed|null  $default
59
     *
60
     * @return mixed
61
     */
62 596
    private function config($key, $default = null)
63
    {
64 596
        return $this->app['config']->get("log-viewer.route.$key", $default);
65
    }
66
}
67