Passed
Push — master ( c9b334...7badbc )
by Ryosuke
12:43 queued 02:43
created

CompilesGroupLimitByMultipleColumnPartition   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 4
c 1
b 0
f 0
dl 0
loc 16
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A compileRowNumber() 0 7 1
1
<?php
2
3
namespace Mpyw\ComposhipsEagerLimit\Database\Query\Grammar\Concerns;
4
5
/**
6
 * Trait CompilesGroupLimitByMultipleColumnPartition
7
 */
8
trait CompilesGroupLimitByMultipleColumnPartition
9
{
10
    /**
11
     * Compile a row number clause.
12
     *
13
     * @param  array|string $partition
14
     * @param  string       $orders
15
     * @return string
16
     */
17 24
    protected function compileRowNumber($partition, $orders)
18
    {
19 24
        $partition = 'partition by ' . implode(', ', array_map([$this, 'wrap'], (array)$partition));
20
21 24
        $over = trim($partition . ' ' . $orders);
22
23 24
        return ', row_number() over (' . $over . ') as laravel_row';
24
    }
25
}
26