Completed
Push — develop ( a86374...2e7b9b )
by Enea
02:33
created

DriversResolver   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A resolve() 0 8 2
A prepareForDatabase() 0 3 1
A __construct() 0 3 1
A make() 0 3 1
1
<?php
2
/**
3
 * Created on 04/03/18 by enea dhack.
4
 */
5
6
namespace Enea\Authorization;
7
8
use Enea\Authorization\Authorizer as AuthorizerContract;
9
use Enea\Authorization\Drivers\Database\Authorizer as DatabaseAuthorizer;
10
use Enea\Authorization\Exceptions\UnsupportedDriverException;
11
use Enea\Authorization\Support\Config;
12
use Enea\Authorization\Support\Drivers;
13
use Illuminate\Contracts\Container\Container;
14
15
class DriversResolver
16
{
17
    private $app;
18
19 47
    public function __construct(Container $app)
20
    {
21 47
        $this->app = $app;
22 47
    }
23
24 47
    public function make(): void
25
    {
26 47
        $this->resolve(Config::getDriver());
27 47
    }
28
29 47
    protected function resolve(string $driver): void
30
    {
31
        switch ($driver) {
32 47
            case Drivers::DATABASE:
33 47
                $this->prepareForDatabase();
34 47
                break;
35
            default:
36 1
                throw new UnsupportedDriverException($driver);
37
        }
38 47
    }
39
40 47
    private function prepareForDatabase(): void
41
    {
42 47
        $this->app->bind(AuthorizerContract::class, DatabaseAuthorizer::class);
43 47
    }
44
}
45