Passed
Push — master ( 5228b2...495136 )
by Jonas
30:19 queued 20:21
created

HasOneOrManyThrough   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 88.89%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 27
ccs 8
cts 9
cp 0.8889
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A limit() 0 17 4
1
<?php
2
3
namespace Staudenmeir\EloquentEagerLimit\Relations;
4
5
use Illuminate\Database\Query\Grammars\MySqlGrammar;
6
7
trait HasOneOrManyThrough
8
{
9
    use HasLimit;
10
11
    /**
12
     * Set the "limit" value of the query.
13
     *
14
     * @param int $value
15
     * @return $this
16
     */
17 32
    public function limit($value)
18
    {
19 32
        if ($this->farParent->exists) {
20 8
            $this->query->limit($value);
21
        } else {
22 24
            $column = $this->getQualifiedFirstKeyName();
0 ignored issues
show
Bug introduced by
It seems like getQualifiedFirstKeyName() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

22
            /** @scrutinizer ignore-call */ 
23
            $column = $this->getQualifiedFirstKeyName();
Loading history...
23
24 24
            $grammar = $this->query->getQuery()->getGrammar();
25
26 24
            if ($grammar instanceof MySqlGrammar && $grammar->useLegacyGroupLimit($this->query->getQuery())) {
27
                $column = 'laravel_through_key';
28
            }
29
30 24
            $this->query->groupLimit($value, $column);
31
        }
32
33 32
        return $this;
34
    }
35
}
36