Passed
Pull Request — master (#127)
by Wouter
02:39
created

SetValueHolderMethod   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 5
c 1
b 0
f 0
dl 0
loc 9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
1
<?php
2
3
namespace Zenstruck\Foundry\Proxy;
4
5
use Laminas\Code\Generator\ParameterGenerator;
6
use Laminas\Code\Generator\PropertyGenerator;
7
use ProxyManager\Generator\MethodGenerator;
8
9
/**
10
 * Adds a setter method for the proxied value holder.
11
 *
12
 * The ProxyManager doesn't allow replacing the value holder, but this is
13
 * required if Foundry is used across Symfony kernel reboots (which is
14
 * common in HTTP tests).
15
 *
16
 * @author Wouter de Jong <[email protected]>
17
 */
18
class SetValueHolderMethod extends MethodGenerator
19
{
20
    public function __construct(PropertyGenerator $valueHolderProperty)
21
    {
22
        parent::__construct('setWrappedValueHolder');
23
24
        $this->setParameter(new ParameterGenerator('wrappedValueHolder'));
25
        $this->setReturnType('void');
26
        $this->setBody('$this->'.$valueHolderProperty->getName().' = $wrappedValueHolder;');
27
    }
28
}
29