MagicMethodGenerator::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
ccs 9
cts 9
cp 1
rs 9.7333
cc 2
nc 2
nop 3
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManager\Generator;
6
7
use ReflectionClass;
8
use function strtolower;
9
10
/**
11
 * Method generator for magic methods
12
 */
13
class MagicMethodGenerator extends MethodGenerator
14
{
15
    /**
16
     * @param mixed[] $parameters
17
     */
18
    public function __construct(ReflectionClass $originalClass, string $name, array $parameters = [])
19 5
    {
20
        parent::__construct(
21 5
            $name,
22 5
            $parameters,
23 5
            self::FLAG_PUBLIC
24 5
        );
25
26
        $this->setReturnsReference(strtolower($name) === '__get');
27 5
28
        if (! $originalClass->hasMethod($name)) {
29 5
            return;
30 2
        }
31
32
        $this->setReturnsReference($originalClass->getMethod($name)->returnsReference());
33 3
    }
34
}
35