Completed
Push — master ( 509987...79a3d2 )
by Rasmus
02:45
created

Limit   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 25
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A limit() 0 10 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
    /**
14
     * @var int|null
15
     */
16
    protected $limit;
17
18
    /**
19
     * @param int $limit max. number of records
20
     *
21
     * @return $this
22
     *
23
     * @throws InvalidArgumentException if the given limit is less than 1
24
     */
25
    public function limit($limit)
0 ignored issues
show
Best Practice introduced by
Using PHP4-style constructors that are named like the class is not recommend; better use the more explicit __construct method.
Loading history...
26
    {
27
        if ($limit < 1) {
28
            throw new InvalidArgumentException("limit out of range: {$limit}");
29
        }
30
31
        $this->limit = $limit;
32
33
        return $this;
34
    }
35
}
36