OrExpr::__construct()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 3.0052

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 20
ccs 11
cts 12
cp 0.9167
rs 9.9
cc 3
nc 4
nop 3
crap 3.0052
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Noitran\RQL\Expressions;
6
7
use Noitran\RQL\Exceptions\ExpressionException;
8
9
/**
10
 * Class OrExpr.
11
 */
12
class OrExpr extends AbstractExpr
13
{
14
    /**
15
     * OrExpr constructor.
16
     *
17
     * @param string|null $relation
18
     * @param string $column
19
     * @param $value
20
     *
21
     * @throws ExpressionException
22
     */
23 1
    public function __construct(?string $relation, string $column, $value)
24
    {
25 1
        if (\is_string($value)) {
26 1
            $value = array_filter(
27 1
                $this->valueToArray('|', trim($value))
28
            );
29
        }
30
31 1
        if (\count($value) < 2) {
32
            throw new ExpressionException('The number of "values" must be greater than one');
33
        }
34
35 1
        parent::__construct(
36 1
            $relation,
37 1
            $column,
38 1
            $value
39
        );
40
41 1
        $this->setExpression('$or');
42 1
        $this->setOperator();
43 1
    }
44
}
45