Passed
Push — master ( f86dae...b646e1 )
by Philippe
01:11
created

SquantoManagerServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
dl 0
loc 45
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A boot() 0 17 3
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 55
    public function boot()
25
    {
26
        // Require helper files
27 55
        if(!function_exists('htmLawed')) {
28 1
            require_once dirname(__FILE__) . "/Manager/utils/vendors/htmlLawed.php";
29
        }
30
31 55
        require_once dirname(__FILE__) . "/Manager/utils/helpers.php";
32
33 55
        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 55
            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 55
        $this->loadViewsFrom(realpath(__DIR__ . '/Manager/Http/views'), 'squanto');
40 55
    }
41
42
    /**
43
     * Register our translator
44
     *
45
     * @return void
46
     */
47 55
    public function register()
48
    {
49
        //
50 55
    }
51
}
52