Completed
Pull Request — master (#364)
by ARCANEDEV
12:52
created

RouteServiceProvider::routeAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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 4
rs 10
c 0
b 0
f 0
ccs 0
cts 2
cp 0
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
 * @package  Arcanedev\LogViewer\Providers
14
 * @author   ARCANEDEV <[email protected]>
15
 */
16
class RouteServiceProvider extends ServiceProvider
17
{
18
    /* -----------------------------------------------------------------
19
     |  Getters & Setters
20
     | -----------------------------------------------------------------
21
     */
22
23
    /**
24
     * Check if routes is enabled
25
     *
26
     * @return bool
27
     */
28 592
    public function isEnabled(): bool
29
    {
30 592
        return (bool) $this->config('enabled', false);
31
    }
32
33
    /* -----------------------------------------------------------------
34
     |  Main Methods
35
     | -----------------------------------------------------------------
36
     */
37
38
    /**
39
     * Boot the service provider.
40
     */
41 592
    public function boot(): void
42
    {
43 592
        if ($this->isEnabled()) {
44 592
            $this->routes(function () {
45 296
                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...
46 592
            });
47
        }
48 592
    }
49
50
    /* -----------------------------------------------------------------
51
     |  Other Methods
52
     | -----------------------------------------------------------------
53
     */
54
55
    /**
56
     * Get config value by key
57
     *
58
     * @param  string      $key
59
     * @param  mixed|null  $default
60
     *
61
     * @return mixed
62
     */
63 592
    private function config($key, $default = null)
64
    {
65 592
        return $this->app['config']->get("log-viewer.route.$key", $default);
66
    }
67
}
68