Completed
Pull Request — master (#9)
by Philippe
05:11
created

SquantoManagerServiceProvider::boot()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 0
dl 0
loc 17
ccs 8
cts 8
cp 1
crap 3
rs 9.7
c 0
b 0
f 0
1
<?php
2
3
namespace Thinktomorrow\Squanto;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class SquantoManagerServiceProvider extends ServiceProvider
8
{
9
    protected $defer = false;
10
11
    /**
12
     * @return array
13
     */
14
    public function provides()
15
    {
16
        return [];
17
    }
18
19
    /**
20
     * Bootstrap any application services.
21
     *
22
     * @return void
23
     */
24 54
    public function boot()
25
    {
26
        // Require helper files
27 54
        if(!function_exists('htmLawed')) {
28 1
            require_once dirname(__FILE__) . "/Manager/utils/vendors/htmlLawed.php";
29
        }
30
31 54
        require_once dirname(__FILE__) . "/Manager/utils/helpers.php";
32
33 54
        if (! $this->app->routesAreCached()) {
0 ignored issues
show
Bug introduced by
The method routesAreCached does only exist in Illuminate\Foundation\Application, but not in Illuminate\Contracts\Foundation\Application.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
34 54
            require __DIR__ . '/Manager/Http/routes/web.php';
35
        }
36
37
        // Register squanto viewfiles under squanto:: namespace
38
        // allow to override them by making a view file under the resources/views/vendor/squanto location
39 54
        $this->loadViewsFrom(realpath(__DIR__ . '/Manager/Http/views'), 'squanto');
40 54
    }
41
42
    /**
43
     * Register our translator
44
     *
45
     * @return void
46
     */
47 54
    public function register()
48
    {
49
        //
50 54
    }
51
}
52