Passed
Push — main ( 05af85...57964c )
by Jonas
03:34
created

HasEagerLimit   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 15
c 1
b 0
f 0
dl 0
loc 30
ccs 13
cts 13
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getEagerLimitGrammar() 0 21 4
1
<?php
2
3
namespace Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Eloquent\Relations\Traits;
4
5
use Staudenmeir\EloquentEagerLimit\Relations\HasLimit;
6
use Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Query\Grammars\MySqlGrammar;
7
use Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Query\Grammars\PostgresGrammar;
8
use Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Query\Grammars\SQLiteGrammar;
9
use Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Query\Grammars\SqlServerGrammar;
0 ignored issues
show
Bug introduced by
The type Staudenmeir\EloquentEage...ammars\SqlServerGrammar was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
trait HasEagerLimit
12
{
13
    use HasLimit;
14
15
    /**
16
     * Get the eager limit grammar.
17
     *
18
     * @return \Staudenmeir\EloquentEagerLimitXLaravelAdjacencyList\Query\Grammars\EagerLimitGrammar
19
     */
20 32
    public function getEagerLimitGrammar()
21
    {
22 32
        $connection = $this->query->getQuery()->getConnection();
23 32
        $driver = $connection->getDriverName();
24
25 32
        switch ($driver) {
26 32
            case 'mysql':
27 16
                return $connection->withTablePrefix(
28 16
                    new MySqlGrammar()
29
                );
30 16
            case 'pgsql':
31 8
                return $connection->withTablePrefix(
32 8
                    new PostgresGrammar()
33
                );
34 8
            case 'sqlite':
35 8
                return $connection->withTablePrefix(
36 8
                    new SQLiteGrammar()
37
                );
38
        }
39
40
        throw new RuntimeException('This database is not supported.'); // @codeCoverageIgnore
0 ignored issues
show
Bug introduced by
The type Staudenmeir\EloquentEage...Traits\RuntimeException was not found. Did you mean RuntimeException? If so, make sure to prefix the type with \.
Loading history...
41
    }
42
}
43