AbstractCondition::__call()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder\Conditions;
6
7
use Puzzle\QueryBuilder\Condition;
8
use Puzzle\QueryBuilder\Conditions\Binaries\AndCondition;
9
use Puzzle\QueryBuilder\Conditions\Binaries\OrCondition;
10
11
abstract class AbstractCondition implements Condition
12
{
13 20
    public function _and(Condition $condition): AndCondition
14
    {
15 20
        return new AndCondition($this, $condition);
16
    }
17
18 12
    public function _or(Condition $condition): OrCondition
19
    {
20 12
        return new OrCondition($this, $condition);
21
    }
22
23 30
    public function __call(string $methodName, $arguments): Condition
24
    {
25 30
        $method = '_' . $methodName;
26
27 30
        if(method_exists($this, $method))
28
        {
29 28
            if(array_key_exists(0, $arguments))
30
            {
31 27
                return $this->$method($arguments[0]);
32
            }
33
34 1
            throw new \RuntimeException(sprintf("Missing parameter 1 for %s", $method));
35
        }
36
37 2
        throw new \LogicException(sprintf("Unkown method %s", $method));
38
    }
39
}
40