Conditions | 5 |
Paths | 4 |
Total Lines | 23 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 5.025 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
27 | 7 | public function limit($value) |
|
28 | { |
||
29 | 7 | if ($this->farParent->exists) { |
|
30 | 5 | $this->query->limit($value); |
|
31 | } else { |
||
32 | 2 | if (!class_exists('Staudenmeir\EloquentEagerLimit\Builder')) { |
|
33 | $message = 'Please install staudenmeir/eloquent-eager-limit and add the HasEagerLimit trait as shown in the README.'; // @codeCoverageIgnore |
||
34 | |||
35 | throw new RuntimeException($message); // @codeCoverageIgnore |
||
36 | } |
||
37 | |||
38 | 2 | $column = $this->getQualifiedFirstKeyName(); |
|
|
|||
39 | |||
40 | 2 | $grammar = $this->query->getQuery()->getGrammar(); |
|
41 | |||
42 | 2 | if ($grammar instanceof MySqlGrammar && $grammar->useLegacyGroupLimit($this->query->getQuery())) { |
|
43 | $column = 'laravel_through_key'; |
||
44 | } |
||
45 | |||
46 | 2 | $this->query->groupLimit($value, $column); |
|
47 | } |
||
48 | |||
49 | 7 | return $this; |
|
50 | } |
||
52 |