Completed
Push — 2.x ( 8f6930...447f85 )
by Akihito
01:14
created

Inject   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isOptional() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Ray\Di\Di;
6
7
use Attribute;
8
use Doctrine\Common\Annotations\NamedArgumentConstructorAnnotation;
9
10
/**
11
 * Annotates your class methods into which the Injector should inject values
12
 *
13
 * @Annotation
14
 * @Target("METHOD")
15
 */
16
#[Attribute(Attribute::TARGET_METHOD | Attribute::TARGET_PARAMETER)]
17
final class Inject implements InjectInterface, NamedArgumentConstructorAnnotation
18
{
19
    /**
20
     * If true, and the appropriate binding is not found, the Injector will skip injection of this method or field rather than produce an error.
21
     *
22
     * @var bool
23
     */
24
    public $optional = false;
25
26
    /**
27
     * @SuppressWarnings(PHPMD.BooleanArgumentFlag)
28
     */
29
    public function __construct(bool $optional = false)
30
    {
31
        $this->optional = $optional;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function isOptional(): bool
38
    {
39
        return $this->optional;
40
    }
41
}
42