SetMethodSuffixInterceptor::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 8
cts 8
cp 1
rs 9.8333
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\AccessInterceptor\MethodGenerator;
6
7
use Closure;
8
use Laminas\Code\Generator\Exception\InvalidArgumentException;
9
use Laminas\Code\Generator\ParameterGenerator;
10
use Laminas\Code\Generator\PropertyGenerator;
11
use ProxyManager\Generator\MethodGenerator;
12
13
/**
14
 * Implementation for {@see \ProxyManager\Proxy\AccessInterceptorInterface::setMethodSuffixInterceptor}
15
 * for access interceptor objects
16
 */
17
class SetMethodSuffixInterceptor extends MethodGenerator
18
{
19
    /**
20
     * Constructor
21
     *
22
     * @throws InvalidArgumentException
23
     */
24
    public function __construct(PropertyGenerator $suffixInterceptor)
25
    {
26 1
        parent::__construct('setMethodSuffixInterceptor');
27
28 1
        $interceptor = new ParameterGenerator('suffixInterceptor');
29
30 1
        $interceptor->setType(Closure::class);
31
        $interceptor->setDefaultValue(null);
32 1
        $this->setParameter(new ParameterGenerator('methodName', 'string'));
33 1
        $this->setParameter($interceptor);
34 1
        $this->setReturnType('void');
35 1
        $this->setBody('$this->' . $suffixInterceptor->getName() . '[$methodName] = $suffixInterceptor;');
36 1
    }
37
}
38