ClassGeneratorUtils   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A addMethodIfNotFinal() 0 15 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Generator\Util;
6
7
use Laminas\Code\Generator\ClassGenerator;
8
use Laminas\Code\Generator\MethodGenerator;
9
use ReflectionClass;
10
11
/**
12
 * Util class to help to generate code
13
 */
14
final class ClassGeneratorUtils
15
{
16
    public static function addMethodIfNotFinal(
17 2
        ReflectionClass $originalClass,
18
        ClassGenerator $classGenerator,
19
        MethodGenerator $generatedMethod
20
    ) : bool {
21
        $methodName = $generatedMethod->getName();
22 2
23
        if ($originalClass->hasMethod($methodName) && $originalClass->getMethod($methodName)->isFinal()) {
24 2
            return false;
25 1
        }
26
27
        $classGenerator->addMethodFromGenerator($generatedMethod);
28 1
29
        return true;
30 1
    }
31
}
32