ComposersServiceProvider::boot()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 11
nc 1
nop 0
1
<?php namespace Usman\Guardian\Composers;
2
3
use Illuminate\Support\ServiceProvider;
4
5
class ComposersServiceProvider extends ServiceProvider {
6
7
    /**
8
     * Registers the view composers after the application is booted.
9
     *
10
     * @return void
11
     */
12
    public function boot()
13
    {
14
        $this->app->view->composers([
0 ignored issues
show
Bug introduced by
Accessing view on the interface Illuminate\Contracts\Foundation\Application suggest that you code against a concrete implementation. How about adding an instanceof check?

If you access a property on an interface, you most likely code against a concrete implementation of the interface.

Available Fixes

  1. Adding an additional type check:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeInterface $object) {
        if ($object instanceof SomeClass) {
            $a = $object->a;
        }
    }
    
  2. Changing the type hint:

    interface SomeInterface { }
    class SomeClass implements SomeInterface {
        public $a;
    }
    
    function someFunction(SomeClass $object) {
        $a = $object->a;
    }
    
Loading history...
15
            'Usman\Guardian\Composers\RoleOptionsComposer' => [
16
                'guardian::partials.user.add',
17
                'guardian::partials.user.edit',
18
                'guardian::partials.user.search-form',
19
                'guardian::partials.capability.add',
20
                'guardian::partials.capability.edit'
21
            ],
22
            'Usman\Guardian\Composers\CapabilityOptionsComposer' => [
23
                'guardian::partials.role.add',
24
                'guardian::partials.role.edit'
25
            ]
26
        ]);
27
    }
28
29
    /**
30
     * Register the service provider.
31
     *
32
     * @return void
33
     */
34
    public function register()
35
    {
36
        //
37
    }
38
39
}
40