Completed
Pull Request — master (#247)
by Michael
02:36
created

InternalAnnotations::createMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 51
dl 0
loc 66
rs 9.069
c 0
b 0
f 0
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Metadata;
6
7
use Doctrine\Annotations\Annotation\Attribute;
8
use Doctrine\Annotations\Annotation\Attributes;
9
use Doctrine\Annotations\Annotation\Enum;
10
use Doctrine\Annotations\Annotation\Target;
11
12
/**
13
 * @internal
14
 */
15
final class InternalAnnotations
16
{
17
    public static function createMetadata() : MetadataCollection
18
    {
19
        return new TransientMetadataCollection(
20
            new AnnotationMetadata(
21
                Attribute::class,
22
                AnnotationTarget::annotation(),
23
                false,
24
                new PropertyMetadata(
25
                    'name',
26
                    ['type' => 'string'],
27
                    true,
28
                    true
29
                ),
30
                new PropertyMetadata(
31
                    'type',
32
                    ['type' => 'string'],
33
                    true
34
                ),
35
                new PropertyMetadata(
36
                    'required',
37
                    ['type' => 'boolean']
38
                )
39
            ),
40
            new AnnotationMetadata(
41
                Attributes::class,
42
                AnnotationTarget::class(),
43
                false,
44
                new PropertyMetadata(
45
                    'value',
46
                    [
47
                        'type'       => 'array',
48
                        'array_type' =>Attribute::class,
49
                        'value'      =>'array<' . Attribute::class . '>',
50
                    ],
51
                    true,
52
                    true
53
                )
54
            ),
55
            new AnnotationMetadata(
56
                Enum::class,
57
                AnnotationTarget::property(),
58
                true,
59
                new PropertyMetadata(
60
                    'value',
61
                    ['type' => 'array'],
62
                    true,
63
                    true
64
                ),
65
                new PropertyMetadata(
66
                    'literal',
67
                    ['type' => 'array']
68
                )
69
            ),
70
            new AnnotationMetadata(
71
                Target::class,
72
                AnnotationTarget::class(),
73
                true,
74
                new PropertyMetadata(
75
                    'value',
76
                    [
77
                        'type'      =>'array',
78
                        'array_type'=>'string',
79
                        'value'     =>'array<string>',
80
                    ],
81
                    false,
82
                    true
83
                )
84
            )
85
        );
86
    }
87
}
88