MagicSet   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\RemoteObject\MethodGenerator;
6
7
use Laminas\Code\Generator\Exception\InvalidArgumentException;
8
use Laminas\Code\Generator\ParameterGenerator;
9
use Laminas\Code\Generator\PropertyGenerator;
10
use ProxyManager\Generator\MagicMethodGenerator;
11
use ReflectionClass;
12
use function var_export;
13
14
/**
15
 * Magic `__set` for remote objects
16
 */
17
class MagicSet extends MagicMethodGenerator
18
{
19
    /**
20
     * Constructor
21
     *
22
     * @throws InvalidArgumentException
23
     */
24
    public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty)
25 1
    {
26
        parent::__construct(
27 1
            $originalClass,
28 1
            '__set',
29 1
            [new ParameterGenerator('name'), new ParameterGenerator('value')]
30 1
        );
31
32
        $this->setDocBlock('@param string \$name\n@param mixed \$value');
33 1
        $this->setBody(
34 1
            '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true)
35 1
            . ', \'__set\', array($name, $value));' . "\n\n"
36 1
            . 'return $return;'
37 1
        );
38
    }
39
}
40