Passed
Push — master ( 779d84...3d5507 )
by Vincent
05:31
created

MagicCallForwarding::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 2
nc 2
nop 2
crap 2
1
<?php
2
3
namespace Bdf\Form\Util;
4
5
use Bdf\Form\ElementBuilderInterface;
6
7
/**
8
 * Forward __call() magic method to an inner element builder
9
 */
10
trait MagicCallForwarding
11
{
12
    /**
13
     * Forward call to the inner element builder
14
     *
15
     * @param string $name
16
     * @param array $arguments
17
     *
18
     * @return $this|mixed
19
     */
20 97
    final public function __call(string $name, array $arguments)
21
    {
22 97
        $builder = $this->getElementBuilder();
23 97
        $return = $builder->$name(...$arguments);
24
25 97
        return $return === $builder ? $this : $return;
26
    }
27
28
    /**
29
     * Get the inner element builder
30
     *
31
     * @return ElementBuilderInterface
32
     */
33
    abstract protected function getElementBuilder(): ElementBuilderInterface;
34
}
35