Completed
Push — master ( e02933...197ad6 )
by ARCANEDEV
08:16
created

Manager::createDriver()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 14
ccs 0
cts 9
cp 0
crap 12
rs 9.4285
1
<?php namespace Arcanedev\Support;
2
3
use Illuminate\Support\Manager as IlluminateManager;
4
use Illuminate\Support\Str;
5
use InvalidArgumentException;
6
7
/**
8
 * Class     Manager
9
 *
10
 * @package  Arcanedev\Support
11
 * @author   ARCANEDEV <[email protected]>
12
 */
13
abstract class Manager extends IlluminateManager
14
{
15
    /**
16
     * Create a new driver instance.
17
     *
18
     * @param  string  $driver
19
     *
20
     * @return mixed
21
     */
22
    protected function createDriver($driver)
23
    {
24
        $method = 'create'.Str::studly($driver).'Driver';
25
26
        // We'll check to see if a creator method exists for the given driver. If not we
27
        // will check for a custom driver creator, which allows developers to create
28
        // drivers using their own customized driver creator Closure to create it.
29
        if (isset($this->customCreators[$driver]))
30
            return $this->callCustomCreator($driver);
31
        elseif (method_exists($this, $method))
32
            return $this->$method();
33
34
        throw new InvalidArgumentException("Driver [$driver] not supported.");
35
    }
36
}
37