RouteServiceProvider::isEnabled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\RouteViewer\Providers;
6
7
use Arcanedev\RouteViewer\Http\Routes\RouteViewerRoutes;
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
     |  Main Methods
19
     | -----------------------------------------------------------------
20
     */
21
22
    /**
23
     * Boot the service provider.
24
     */
25 48
    public function boot(): void
26
    {
27 48
        if ($this->isEnabled()) {
28 48
            $this->routes(function () {
29 24
                static::mapRouteClasses([RouteViewerRoutes::class]);
0 ignored issues
show
Documentation introduced by
array(\Arcanedev\RouteVi...uteViewerRoutes::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...
30 48
            });
31
        }
32 48
    }
33
34
    /* -----------------------------------------------------------------
35
     |  Check Methods
36
     | -----------------------------------------------------------------
37
     */
38
39
    /**
40
     * Check if routes is enabled.
41
     *
42
     * @return bool
43
     */
44 48
    public function isEnabled(): bool
45
    {
46 48
        return (bool) ($this->app['config']['route-viewer.route.enabled'] ?? false);
47
    }
48
}
49