Passed
Push — develop ( 355f63...51016a )
by Mathieu
02:23
created

AddChild   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 9
dl 0
loc 34
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Neimheadh\SonataAnnotationBundle\Annotation\Sonata;
6
7
use Attribute;
8
use Neimheadh\SonataAnnotationBundle\Annotation\AbstractAnnotation;
9
use ReflectionException;
10
11
/**
12
 * Add child annotation.
13
 *
14
 * Add child admin to current admin class or admin annotated model.
15
 *
16
 * @Annotation
17
 * @Target("CLASS")
18
 *
19
 * @author Marko Kunic <[email protected]>
20
 * @author Mathieu Wambre <[email protected]>
21
 */
22
#[Attribute(Attribute::TARGET_CLASS)]
23
final class AddChild extends AbstractAnnotation
24
{
25
26
    /**
27
     * Child model class.
28
     *
29
     * @var string|null
30
     */
31
    public ?string $class = null;
32
33
    /**
34
     * Reverse field.
35
     *
36
     * @var string|null
37
     */
38
    public ?string $field = null;
39
40
    /**
41
     * @param string|array|null $class Model class or annotation parameters.
42
     * @param string|null       $field Reverse field.
43
     *
44
     * @throws ReflectionException
45
     */
46
    public function __construct(
47
        $class = null,
48
        ?string $field = null
49
    ) {
50
        $this->field = $field;
51
52
        if (is_array($class)) {
53
            $this->initAnnotation($class);
54
        } else {
55
            $this->class = $class;
56
        }
57
    }
58
59
}
60