Completed
Pull Request — master (#746)
by
unknown
83:49 queued 18:51
created

AbstractFluentAdapter::getConnection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
/*
4
 * This file is part of OAuth 2.0 Laravel.
5
 *
6
 * (c) Luca Degasperi <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LucaDegasperi\OAuth2Server\Storage;
13
14
use Illuminate\Database\ConnectionResolverInterface as Resolver;
15
use League\OAuth2\Server\Storage\AbstractStorage;
16
17
/**
18
 * This is the abstract fluent adapter class.
19
 *
20
 * @author Luca Degasperi <[email protected]>
21
 */
22
abstract class AbstractFluentAdapter extends AbstractStorage
23
{
24
    /**
25
     * The connection resolver instance.
26
     *
27
     * @var \Illuminate\Database\ConnectionResolverInterface
28
     */
29
    protected $resolver;
30
31
    /**
32
     * The connection name.
33
     *
34
     * @var string
35
     */
36
    protected $connectionName;
37
38
    /**
39
     * Create a new abstract fluent adapter instance.
40
     *
41
     * @param \Illuminate\Database\ConnectionResolverInterface $resolver
42
     */
43 108
    public function __construct(Resolver $resolver)
44
    {
45 108
        $this->resolver = $resolver;
46 108
        $this->connectionName = null;
47 108
    }
48
49
    /**
50
     * Set the resolver.
51
     *
52
     * @param \Illuminate\Database\ConnectionResolverInterface $resolver
53
     */
54
    public function setResolver(Resolver $resolver)
55
    {
56
        $this->resolver = $resolver;
57
    }
58
59
    /**
60
     * Get the resolver.
61
     *
62
     * @return \Illuminate\Database\ConnectionResolverInterface
63
     */
64
    public function getResolver()
65
    {
66
        return $this->resolver;
67
    }
68
69
    /**
70
     * Set the connection name.
71
     *
72
     * @param string $connectionName
73
     *
74
     * @return void
75
     */
76
    public function setConnectionName($connectionName)
77
    {
78
        $this->connectionName = $connectionName;
79
    }
80
81
    /**
82
     * Get the connection.
83
     *
84
     * @return \Illuminate\Database\ConnectionInterface
85
     */
86 108
    protected function getConnection()
87
    {
88 108
        return $this->resolver->connection($this->connectionName);
89
    }
90
}
91