InterceptedMethod   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 4
dl 0
loc 30
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateMethod() 0 24 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator;
6
7
use Laminas\Code\Generator\Exception\InvalidArgumentException;
8
use Laminas\Code\Generator\PropertyGenerator;
9
use Laminas\Code\Reflection\MethodReflection;
10
use ProxyManager\Generator\MethodGenerator;
11
use ProxyManager\ProxyGenerator\AccessInterceptorScopeLocalizer\MethodGenerator\Util\InterceptorGenerator;
12
use function implode;
13
14
/**
15
 * Method with additional pre- and post- interceptor logic in the body
16
 */
17
class InterceptedMethod extends MethodGenerator
18
{
19
    /**
20
     * @throws InvalidArgumentException
21
     */
22
    public static function generateMethod(
23 2
        MethodReflection $originalMethod,
24
        PropertyGenerator $prefixInterceptors,
25
        PropertyGenerator $suffixInterceptors
26
    ) : self {
27
        /** @var self $method */
28
        $method          = static::fromReflectionWithoutBodyAndDocBlock($originalMethod);
29 2
        $forwardedParams = [];
30 2
31
        foreach ($originalMethod->getParameters() as $parameter) {
32 2
            $forwardedParams[] = ($parameter->isVariadic() ? '...' : '') . '$' . $parameter->getName();
0 ignored issues
show
Bug introduced by
The method isVariadic() does not seem to exist on object<Laminas\Code\Refl...on\ParameterReflection>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33 2
        }
34
35
        $method->setBody(InterceptorGenerator::createInterceptedMethodBody(
36 2
            '$returnValue = parent::'
37
            . $originalMethod->getName() . '(' . implode(', ', $forwardedParams) . ');',
38 2
            $method,
39 2
            $prefixInterceptors,
40 2
            $suffixInterceptors,
41 2
            $originalMethod
42 2
        ));
43
44
        return $method;
45 2
    }
46
}
47