Completed
Push — master ( e43e24...a5d827 )
by ARCANEDEV
05:31
created

ComposerServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 4 1
A boot() 0 7 1
1
<?php namespace Arcanesoft\Auth\Providers;
2
3
use Arcanedev\Support\ServiceProvider;
4
use Arcanesoft\Auth\ViewComposers;
5
6
/**
7
 * Class     ComposerServiceProvider
8
 *
9
 * @package  Arcanesoft\Auth\Providers
10
 * @author   ARCANEDEV <[email protected]>
11
 */
12
class ComposerServiceProvider extends ServiceProvider
13
{
14
    /* ------------------------------------------------------------------------------------------------
15
     |  Main Functions
16
     | ------------------------------------------------------------------------------------------------
17
     */
18
    /**
19
     * Register the service provider.
20
     */
21
    public function register()
22
    {
23
        //
24
    }
25
26
    /**
27
     * Register bindings in the container.
28
     */
29
    public function boot()
30
    {
31
        view()->composer(
0 ignored issues
show
Bug introduced by
The method composer does only exist in Illuminate\Contracts\View\Factory, but not in Illuminate\View\View.

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...
32
            'auth::foundation.dashboard',
33
            ViewComposers\DashboardComposer::class
34
        );
35
    }
36
}
37