Completed
Pull Request — master (#12)
by Philippe
03:37 queued 01:26
created

SquantoManagerServiceProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
dl 0
loc 40
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A boot() 0 12 2
A register() 0 4 1
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 62
    public function boot()
25
    {
26 62
        require_once dirname(__FILE__) . "/Manager/utils/helpers.php";
27
28 62
        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...
29 62
            require __DIR__ . '/Manager/Http/routes/web.php';
30
        }
31
32
        // Register squanto viewfiles under squanto:: namespace
33
        // allow to override them by making a view file under the resources/views/vendor/squanto location
34 62
        $this->loadViewsFrom(realpath(__DIR__ . '/Manager/Http/views'), 'squanto');
35 62
    }
36
37
    /**
38
     * Register our translator
39
     *
40
     * @return void
41
     */
42 62
    public function register()
43
    {
44
        //
45 62
    }
46
}
47