DecoratorTrait::__call()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pgs\HashIdBundle\Traits;
6
7
use BadMethodCallException;
8
9
trait DecoratorTrait
10
{
11
    protected $object;
12
13
    /**
14
     * @throws BadMethodCallException
15
     *
16
     * @return mixed
17
     */
18 2
    public function __call(string $method, array $arguments)
19
    {
20 2
        if (!method_exists($this->object, $method)) {
21 1
            $message = sprintf('Object %s has no %s() method.', \get_class($this->object), $method);
22 1
            throw new BadMethodCallException($message);
23
        }
24
25 1
        return \call_user_func_array([$this->object, $method], $arguments);
26
    }
27
}
28