ClassGenerator::setImplementedInterfaces()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.9666
cc 1
nc 1
nop 1
ccs 1
cts 1
cp 1
crap 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