Failed Conditions
Pull Request — new-parser-ast-metadata (#2)
by
unknown
02:08
created

InternalAnnotations::getNames()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Metadata;
6
7
use Doctrine\Annotations\Annotation\Annotation;
8
use Doctrine\Annotations\Annotation\Enum;
9
use Doctrine\Annotations\Annotation\IgnoreAnnotation;
10
use Doctrine\Annotations\Annotation\Required;
11
use Doctrine\Annotations\Annotation\Target;
12
use Doctrine\Annotations\Metadata\Type\IntegerType;
13
use Doctrine\Annotations\Metadata\Type\ListType;
14
use Doctrine\Annotations\Metadata\Type\NullType;
15
use Doctrine\Annotations\Metadata\Type\StringType;
16
use Doctrine\Annotations\Metadata\Type\UnionType;
17
use Doctrine\Annotations\Parser\Imports;
18
19
final class InternalAnnotations
20
{
21
    /**
22
     * @return iterable<string>
23
     */
24 12
    public static function getNames() : iterable
25
    {
26 12
        yield Annotation::class;
27 11
        yield Enum::class;
28 10
        yield IgnoreAnnotation::class;
29 9
        yield Required::class;
30 8
        yield Target::class;
31 2
    }
32
33 6
    public static function createMetadata() : MetadataCollection
34
    {
35 6
        return new MetadataCollection(
36 6
            new AnnotationMetadata(
37 6
                Annotation::class,
38 6
                new AnnotationTarget(AnnotationTarget::TARGET_ALL),
39 6
                false
40
            ),
41 6
            new AnnotationMetadata(
42 6
                Enum::class,
43 6
                new AnnotationTarget(AnnotationTarget::TARGET_ALL),
44 6
                true,
45
                [
46 6
                    new PropertyMetadata(
47 6
                        'value',
48 6
                        new ListType(new StringType()),
49 6
                        true
50
                    ),
51 6
                    new PropertyMetadata(
52 6
                        'literal',
53 6
                        new UnionType(new ListType(new StringType()), new NullType())
54
                    ),
55
                ]
56
            ),
57 6
            new AnnotationMetadata(
58 6
                IgnoreAnnotation::class,
59 6
                new AnnotationTarget(AnnotationTarget::TARGET_ALL),
60 6
                true,
61 6
                [new PropertyMetadata(
62 6
                    'names',
63 6
                    new ListType(new StringType()),
64 6
                    true
65
                ),
66
                ]
67
            ),
68 6
            new AnnotationMetadata(
69 6
                Required::class,
70 6
                new AnnotationTarget(AnnotationTarget::TARGET_PROPERTY),
71 6
                false
72
            ),
73 6
            new AnnotationMetadata(
74 6
                Target::class,
75 6
                new AnnotationTarget(AnnotationTarget::TARGET_ALL),
76 6
                true,
77
                [
78 6
                    new PropertyMetadata(
79 6
                        'value',
80 6
                        new UnionType(new ListType(new StringType()), new NullType()),
81 6
                        true
82
                    ),
83 6
                    new PropertyMetadata(
84 6
                        'targets',
85 6
                        new UnionType(new IntegerType(), new NullType())
86
                    ),
87 6
                    new PropertyMetadata(
88 6
                        'literal',
89 6
                        new UnionType(new IntegerType(), new NullType())
90
                    ),
91
                ]
92
            )
93
        );
94
    }
95
96 6
    public static function createImports() : Imports
97
    {
98 6
        return new Imports([
99 6
            'annotation'       => Annotation::class,
100
            'enum'             => Enum::class,
101
            'ignoreannotation' => IgnoreAnnotation::class,
102
            'required'         => Required::class,
103
            'target'           => Target::class,
104
        ]);
105
    }
106
}
107