Completed
Push — master ( 3021dd...73da4d )
by Carlos
04:15
created

ServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 6 1
A provides() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/laravel-shopping-cart.
5
 *
6
 * (c) 2016 overtrue <[email protected]>
7
 */
8
9
namespace Overtrue\LaravelShoppingCart;
10
11
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
12
13
/**
14
 * Service provider for Laravel.
15
 */
16
class ServiceProvider extends LaravelServiceProvider
17
{
18
    /**
19
     * Indicates if loading of the provider is deferred.
20
     *
21
     * @var bool
22
     */
23
    protected $defer = true;
24
25
    /**
26
     * Boot the provider.
27
     */
28
    public function boot()
29
    {
30
        //
31
    }
32
33
    /**
34
     * Register the service provider.
35
     */
36
    public function register()
37
    {
38
        $this->app->singleton([Cart::class => 'cart'], function ($app) {
0 ignored issues
show
Documentation introduced by
array(\Overtrue\LaravelS...\Cart::class => 'cart') is of type array<string|integer,string>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
            return new Cart($app['session'], $app['events']);
40
        });
41
    }
42
43
    /**
44
     * Get the services provided by the provider.
45
     *
46
     * @return array
47
     */
48
    public function provides()
49
    {
50
        return [Cart::class, 'cart'];
51
    }
52
}
53