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

MagicCallForwarding   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 4
c 1
b 0
f 0
dl 0
loc 24
ccs 4
cts 4
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 6 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