Completed
Push — master ( 7cf8d9...f10042 )
by Patrick
19:35 queued 04:05
created

FeatureDetection::connectionResolverDriver()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
crap 2.0625
1
<?php
2
3
namespace ShiftOneLabs\LaravelNomad;
4
5
use Illuminate\Database\Connection;
6
7
class FeatureDetection
8
{
9
    /**
10
     * Resolve the connection via bindings.
11
     *
12
     * @var string
13
     */
14
    const CONNECTION_RESOLVER_BINDINGS = 'bindings';
15
16
    /**
17
     * Resolve the connection via the connection resolver method.
18
     *
19
     * @var string
20
     */
21
    const CONNECTION_RESOLVER_METHOD = 'connection-method';
22
23
    /**
24
     * Determine the driver for resolving the connection.
25
     *
26
     * @return string
27
     */
28 41
    public function connectionResolverDriver()
29
    {
30 41
        if (method_exists(Connection::class, 'resolverFor')) {
31 41
            return self::CONNECTION_RESOLVER_METHOD;
32
        }
33
34
        return self::CONNECTION_RESOLVER_BINDINGS;
35
    }
36
37
    /**
38
     * Check if the connection resolver method is of the given type.
39
     *
40
     * @param  string  $driver
41
     *
42
     * @return bool
43
     */
44 34
    public function isConnectionResolver($driver)
45
    {
46 34
        return $this->connectionResolverDriver() == $driver;
47
    }
48
}
49