NullObjectMethodInterceptor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateMethod() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\ProxyGenerator\NullObject\MethodGenerator;
6
7
use Laminas\Code\Reflection\MethodReflection;
8
use ProxyManager\Generator\MethodGenerator;
9
use ProxyManager\Generator\Util\IdentifierSuffixer;
10
11
/**
12
 * Method decorator for null objects
13
 */
14
class NullObjectMethodInterceptor extends MethodGenerator
15
{
16
    /**
17
     * @return static
18
     */
19
    public static function generateMethod(MethodReflection $originalMethod) : self
20
    {
21 3
        /** @var static $method */
22
        $method = static::fromReflectionWithoutBodyAndDocBlock($originalMethod);
23
24 3
        if ($originalMethod->returnsReference()) {
25
            $reference = IdentifierSuffixer::getIdentifier('ref');
26 3
27 1
            $method->setBody("\$reference = null;\nreturn \$" . $reference . ';');
28
        }
29 1
30
        return $method;
31
    }
32
}
33