PacManager   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 43
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFinkokDriver() 0 9 1
A buildDriver() 0 8 1
A getDefaultDriver() 0 4 1
1
<?php
2
3
namespace FeiMx\Pac;
4
5
use FeiMx\Pac\Contracts\Factory;
6
use FeiMx\Pac\Drivers\FinkokDriver;
7
use Illuminate\Support\Manager;
8
use InvalidArgumentException;
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