LimitSqlsrv::buildEarly()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 0
crap 12
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Sql\Component;
5
6
class LimitSqlsrv extends Limit
7
{
8
    public function buildEarly(): string
9
    {
10
        if ($this->limit > 0 && $this->offset == 0) {
11
            return " TOP {$this->limit}";
12
        }
13
14
        return '';
15
    }
16
17
    public function build(): string
18
    {
19
        if ($this->limit > 0 && $this->offset > 0) {
20
            return PHP_EOL
21
                   . "OFFSET {$this->offset} ROWS "
22
                   . "FETCH NEXT {$this->limit} ROWS ONLY";
23
        }
24
25
        return '';
26
    }
27
}
28