Limit   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 94.12%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 0
loc 46
ccs 16
cts 17
cp 0.9412
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A limit() 0 6 1
A offset() 0 6 1
A page() 0 6 1
A perPage() 0 6 1
A resetLimit() 0 10 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Sql\Clause;
5
6
use Sirius\Sql\Component\Limit as DefaultLimit;
7
use Sirius\Sql\Component\LimitSqlsrv;
8
9
trait Limit
10
{
11
    /**
12
     * @var \Sirius\Sql\Component\Limit
13
     */
14
    protected $limit;
15
16 2
    public function limit(int $limit)
17
    {
18 2
        $this->limit->setLimit($limit);
19
20 2
        return $this;
21
    }
22
23 2
    public function offset(int $offset)
24
    {
25 2
        $this->limit->setOffset($offset);
26
27 2
        return $this;
28
    }
29
30 2
    public function page(int $page)
31
    {
32 2
        $this->limit->setPage($page);
33
34 2
        return $this;
35
    }
36
37 2
    public function perPage(int $perPage)
38
    {
39 2
        $this->limit->setPerPage($perPage);
40
41 2
        return $this;
42
    }
43
44 19
    public function resetLimit()
45
    {
46 19
        if ($this->connection->getDriverName() == 'sqlsrv') {
0 ignored issues
show
Bug introduced by
The property connection does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
47
            $this->limit = new LimitSqlsrv();
48
        } else {
49 19
            $this->limit = new DefaultLimit();
50
        }
51
52 19
        return $this;
53
    }
54
}
55