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

DriversResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
c 0
b 0
f 0
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