Completed
Push — master ( 984f97...beada0 )
by ARCANEDEV
19:57
created

Manager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php namespace Arcanedev\Support;
2
3
use Illuminate\Contracts\Foundation\Application;
4
use Illuminate\Support\Manager as IlluminateManager;
5
use Illuminate\Support\Str;
6
use InvalidArgumentException;
7
8
/**
9
 * Class     Manager
10
 *
11
 * @package  Arcanedev\Support
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
abstract class Manager extends IlluminateManager
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Constructor
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    /**
21
     * Manager constructor.
22
     *
23
     * @param  \Illuminate\Contracts\Foundation\Application  $app
24
     */
25
    public function __construct(Application $app)
26
    {
27
        parent::__construct($app);
0 ignored issues
show
Documentation introduced by
$app is of type object<Illuminate\Contra...Foundation\Application>, but the function expects a object<Illuminate\Foundation\Application>.

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...
28
    }
29
30
    /* ------------------------------------------------------------------------------------------------
31
     |  Main Functions
32
     | ------------------------------------------------------------------------------------------------
33
     */
34
    /**
35
     * Create a new driver instance.
36
     *
37
     * @param  string  $driver
38
     *
39
     * @return mixed
40
     */
41
    protected function createDriver($driver)
42
    {
43
        $method = 'create'.Str::studly($driver).'Driver';
44
45
        // We'll check to see if a creator method exists for the given driver. If not we
46
        // will check for a custom driver creator, which allows developers to create
47
        // drivers using their own customized driver creator Closure to create it.
48
        if (isset($this->customCreators[$driver]))
49
            return $this->callCustomCreator($driver);
50
        elseif (method_exists($this, $method))
51
            return $this->$method();
52
53
        throw new InvalidArgumentException("Driver [$driver] not supported.");
54
    }
55
}
56