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

DriversResolver::prepareForDatabase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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