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