Passed
Push — master ( 222f48...0fa176 )
by y
01:47
created

ValueTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
c 1
b 0
f 1
dl 0
loc 16
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A coalesce() 0 4 1
1
<?php
2
3
namespace Helix\DB\Fluent\Value;
4
5
use Helix\DB\Fluent\AbstractTrait;
6
use Helix\DB\Fluent\Value;
7
8
/**
9
 * Produces type-independent expressions for the instance.
10
 */
11
trait ValueTrait {
12
13
    use AbstractTrait;
14
    use AggregateTrait;
15
    use ComparisonTrait;
16
17
    /**
18
     * `COALESCE($this, ...$values)`
19
     *
20
     * @param scalar[] $values
21
     * @return Value
22
     */
23
    public function coalesce (array $values) {
24
        array_unshift($values, $this);
25
        $values = $this->db->quoteList($values);
26
        return Value::factory($this->db, "COALESCE({$values})");
27
    }
28
}