Completed
Push — 2.x ( bbccfe...868abb )
by Akihito
24s queued 21s
created

Named::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
cc 3
nc 4
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Di;
6
7
use Attribute;
8
9
use function is_array;
10
use function is_string;
11
12
#[Attribute(Attribute::TARGET_PARAMETER)]
13
/**
14
 * Annotates named things
15
 *
16
 * @Annotation
17
 * @Target("METHOD")
18
 */
19
final class Named
20
{
21
    /** @var string */
22
    public $value = '';
23
24
    /**
25
     * @param array{value: string}|string $value
26
     */
27
    public function __construct($value)
28
    {
29
        if (is_array($value)) {
30
            // doctrine/annotations
31
            $this->value = $value['value'];
32
        }
33
34
        if (is_string($value)) {
35
            // php8 attribute
36
            $this->value = $value;
37
        }
38
    }
39
}
40