ClassGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setExtendedClass() 0 8 2
A setImplementedInterfaces() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Generator;
6
7
use Laminas\Code\Generator\ClassGenerator as ZendClassGenerator;
8
use function array_map;
9
use function trim;
10
11
/**
12
 * Class generator that ensures that interfaces/classes that are implemented/extended are FQCNs
13
 */
14
class ClassGenerator extends ZendClassGenerator
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19 1
    public function setExtendedClass($extendedClass) : ZendClassGenerator
20
    {
21 1
        if ($extendedClass) {
22 1
            $extendedClass = '\\' . trim($extendedClass, '\\');
23
        }
24
25 1
        return parent::setExtendedClass($extendedClass);
26
    }
27
28
    /**
29
     * {@inheritDoc}
30
     *
31 1
     * @param array<int, string> $interfaces
32
     *
33 1
     * @psalm-suppress MoreSpecificImplementedParamType parent interface does not specify type of array values
34 1
     */
35
    public function setImplementedInterfaces(array $interfaces) : ZendClassGenerator
36
    {
37 1
        return parent::setImplementedInterfaces(array_map(
38
            static function (string $interface) : string {
39
                return '\\' . trim($interface, '\\');
40
            },
41
            $interfaces
42
        ));
43
    }
44
}
45