Completed
Push — master ( c4aed4...1d2e73 )
by Jorge
01:19
created

PacManager::createFinkokDriver()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
namespace FeiMx\Pac;
4
5
use InvalidArgumentException;
6
use Illuminate\Support\Manager;
7
use FeiMx\Pac\Contracts\Factory;
8
use FeiMx\Pac\Drivers\FinkokDriver;
9
10
class PacManager extends Manager implements Factory
11
{
12
    protected $app;
13
14
    /**
15
     * Create a new manager instance.
16
     *
17
     * @param \Illuminate\Foundation\Application $app
18
     */
19
    public function __construct($app)
20
    {
21
        $this->app = $app;
22
    }
23
24
    protected function createFinkokDriver()
25
    {
26
        $config = $this->app['config']['pac.finkok'];
27
28
        return $this->buildDriver(
29
            FinkokDriver::class,
30
            $config
31
        );
32
    }
33
34
    public function buildDriver($driver, $config)
35
    {
36
        return new $driver(
37
            $config['username'],
38
            $config['password'],
39
            $config['sandbox']
40
        );
41
    }
42
43
    /**
44
     * Get the default driver name.
45
     *
46
     * @return string
47
     */
48
    public function getDefaultDriver()
49
    {
50
        throw new InvalidArgumentException('No Pac driver was specified.');
51
    }
52
}
53