AbstractCondition   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 29
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _and() 0 4 1
A _or() 0 4 1
A __call() 0 16 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