Passed
Pull Request — next (#114)
by Bas
03:28
created

ArangoCommands::useFallback()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
nc 2
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LaravelFreelancerNL\Aranguent\Console\Concerns;
6
7
trait ArangoCommands
8
{
9
    public bool $useArangoDB = false;
10
11 6
    protected function connectionHasArangodbDriver(?string $name): bool
12
    {
13 6
        if ($name == '' && ! $this->arangodbIsDefaultConnection()) {
14
            return false;
15
        }
16 6
        if ($name == '' && $this->arangodbIsDefaultConnection()) {
17 3
            return true;
18
        }
19
20 3
        $connections = config('database.connections');
21
22 3
        return $connections[$name]['driver'] === 'arangodb';
23
    }
24
25 343
    protected function arangodbIsDefaultConnection(): bool
26
    {
27 343
        $connection = \DB::connection();
28
29 343
        return $connection->getDriverName() === 'arangodb';
30
    }
31
32
33 39
    protected function useFallback(): bool
34
    {
35 39
        return !$this->arangodbIsDefaultConnection() && !$this->useArangoDB;
36
    }
37
}
38