MagicUnset::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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 `__unset` method for remote objects
16
 */
17
class MagicUnset extends MagicMethodGenerator
18
{
19
    /**
20
     * Constructor
21
     *
22
     * @throws InvalidArgumentException
23
     */
24
    public function __construct(ReflectionClass $originalClass, PropertyGenerator $adapterProperty)
25
    {
26 1
        parent::__construct($originalClass, '__unset', [new ParameterGenerator('name')]);
27
28 1
        $this->setDocBlock('@param string $name');
29
        $this->setBody(
30 1
            '$return = $this->' . $adapterProperty->getName() . '->call(' . var_export($originalClass->getName(), true)
31 1
            . ', \'__unset\', array($name));' . "\n\n"
32 1
            . 'return $return;'
33 1
        );
34 1
    }
35
}
36