Limit   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 20
ccs 0
cts 5
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A limit() 0 9 2
1
<?php
2
3
namespace mindplay\sql\model\components;
4
5
use InvalidArgumentException;
6
7
/**
8
 * This trait implements the stand-alone `LIMIT` clause (without `OFFSET`) supported
9
 * by the MySQL `UPDATE` and `DELETE` query-builders.
10
 */
11
trait Limit
12
{
13
    protected int|null $limit = null;
14
15
    /**
16
     * @param int $limit max. number of records
17
     *
18
     * @return $this
19
     *
20
     * @throws InvalidArgumentException if the given limit is less than 1
21
     */
22
    public function limit($limit): static
23
    {
24
        if ($limit < 1) {
25
            throw new InvalidArgumentException("limit out of range: {$limit}");
26
        }
27
28
        $this->limit = $limit;
29
30
        return $this;
31
    }
32
}
33