MethodConfig::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 0
c 1
b 0
f 0
nc 1
nop 4
dl 0
loc 20
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Proxy\Config;
6
7
/**
8
 * @internal
9
 *
10
 * A method metadata. {@see ClassConfigFactory} is used for creation. Note that it relies only on PHP type hints and
11
 * ignores PHPDoc completely.
12
 */
13
final class MethodConfig
14
{
15 12
    public function __construct(
16
        /**
17
         * @var string[] A list of modifiers, for example: `['abstract', 'public']`.
18
         */
19
        public array $modifiers,
20
        /**
21
         * @var string A name without parentheses. For example: `getInstance`.
22
         */
23
        public string $name,
24
        /**
25
         * @var ParameterConfig[] A map where key is a {@see ParameterConfig::$name} and value is {@see ParameterConfig}
26
         * instance.
27
         * @psalm-var array<string, ParameterConfig>
28
         */
29
        public array $parameters,
30
        /**
31
         * @var TypeConfig|null Return type config. `null` means no return type specified.
32
         */
33
        public ?TypeConfig $returnType,
34
    ) {
35 12
    }
36
37
    /**
38
     * Whether a method has return type.
39
     *
40
     * @return bool `true` if return type specified and `false` otherwise.
41
     *
42
     * @psalm-assert-if-true TypeConfig $this->returnType
43
     */
44 9
    public function hasReturnType(): bool
45
    {
46 9
        return $this->returnType !== null;
47
    }
48
}
49