Test Setup Failed
Push — master ( 67c757...e205b4 )
by Php Easy Api
03:32
created

ResourceManager::getDriverBuilderInstance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Authenticate\Resource;
4
5
use Resta\Authenticate\AuthenticateProvider;
6
use Resta\Authenticate\Driver\BuilderContract;
7
8
abstract class ResourceManager
9
{
10
    /**
11
     * @var AuthenticateProvider
12
     */
13
    protected $auth;
14
15
    /**
16
     * @var null|object
17
     */
18
    protected $driverBuilderInstance;
19
20
    /**
21
     * ResourceManager constructor.
22
     * @param $auth
23
     */
24
    public function __construct($auth)
25
    {
26
        // if the auth value does not carry
27
        // the authenticateProvider instance value, an exception is thrown.
28
        if(!$auth instanceof AuthenticateProvider){
29
            exception()->runtime('AuthenticateProvider instance is not valid');
30
        }
31
32
        //authenticate instance
33
        $this->auth = $auth;
34
35
        // for the builder, we get the namespace value from the auth object.
36
        // this namespace will take us to the query builder application.
37
        $driverBuilder = $this->auth->getDriverBuilderNamespace();
38
39
        // we get the instance value of
40
        // the imported builder object.
41
        $this->driverBuilderInstance = new $driverBuilder($auth);
42
43
        if(!$this->driverBuilderInstance instanceof BuilderContract){
44
            exception()->runtime($driverBuilder.' is not instance of '.BuilderContract::class);
45
        }
46
    }
47
48
    /**
49
     * get auth
50
     *
51
     * @return AuthenticateProvider
52
     */
53
    public function getAuth()
54
    {
55
        return $this->auth;
56
    }
57
58
    /**
59
     * get driver builder instance
60
     *
61
     * @return object|null
62
     */
63
    public function getDriverBuilderInstance()
64
    {
65
        return $this->driverBuilderInstance;
66
    }
67
}