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

compileRowNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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