Failed Conditions
Push — feature/streamline-console-com... ( e14f21...2f5789 )
by
unknown
15:13
created

ArangoCommands   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 29
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A connectionHasArangodbDriver() 0 12 5
A useFallback() 0 3 2
A arangodbIsDefaultConnection() 0 5 1
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
    protected function connectionHasArangodbDriver(?string $name): bool
12
    {
13
        if ($name == '' && ! $this->arangodbIsDefaultConnection()) {
14
            return false;
15
        }
16
        if ($name == '' && $this->arangodbIsDefaultConnection()) {
17
            return true;
18
        }
19
20
        $connections = config('database.connections');
21
22
        return $connections[$name]['driver'] === 'arangodb';
23
    }
24
25
    protected function arangodbIsDefaultConnection(): bool
26
    {
27
        $connection = \DB::connection();
28
29
        return $connection->getDriverName() === 'arangodb';
30
    }
31
32
33
    protected function useFallback(): bool
34
    {
35
        return !$this->arangodbIsDefaultConnection() && !$this->useArangoDB;
36
    }
37
}
38