SpecificationTrait::andX()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Specification;
12
13
/**
14
 * Specification Trait.
15
 *
16
 * @author Karel Osorio Ramírez <[email protected]>
17
 */
18
trait SpecificationTrait
19
{
20
    /**
21
     * @param string $method
22
     * @param array  $arguments
23
     *
24
     * @throws \BadMethodCallException
25
     */
26
    public function __call($method, array $arguments)
27
    {
28
        if ($method === 'and' || $method === 'or') {
29
            return \call_user_func_array(array($this, $method.'X'), $arguments);
30
        }
31
32
        throw new \BadMethodCallException(\sprintf('Call to undefined method %s::%s', \get_class($this), $method));
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function andX(SpecificationInterface $specification)
39
    {
40
        return new AndSpecification($this, $specification);
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function orX(SpecificationInterface $specification)
47
    {
48
        return new OrSpecification($this, $specification);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function not()
55
    {
56
        return new NotSpecification($this);
57
    }
58
}
59