Passed
Pull Request — master (#247)
by Michael
02:00
created

InternalAnnotations::createMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 66
Code Lines 51

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 48
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 51
dl 0
loc 66
ccs 48
cts 48
cp 1
rs 9.069
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1

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 meta-annotations exposed by the Annotations library to declare custom user-land annotations.
14
 *
15
 * @internal
16
 */
17
final class InternalAnnotations
18
{
19 290
    public static function createMetadata() : MetadataCollection
20
    {
21 290
        return new TransientMetadataCollection(
22 290
            new AnnotationMetadata(
23 290
                Attribute::class,
24 290
                AnnotationTarget::annotation(),
25 290
                false,
26 290
                new PropertyMetadata(
27 290
                    'name',
28 290
                    ['type' => 'string'],
29 290
                    true,
30 290
                    true
31
                ),
32 290
                new PropertyMetadata(
33 290
                    'type',
34 290
                    ['type' => 'string'],
35 290
                    true
36
                ),
37 290
                new PropertyMetadata(
38 290
                    'required',
39 290
                    ['type' => 'boolean']
40
                )
41
            ),
42 290
            new AnnotationMetadata(
43 290
                Attributes::class,
44 290
                AnnotationTarget::class(),
45 290
                false,
46 290
                new PropertyMetadata(
47 290
                    'value',
48
                    [
49 290
                        'type'       => 'array',
50
                        'array_type' =>Attribute::class,
51
                        'value'      =>'array<' . Attribute::class . '>',
52
                    ],
53 290
                    true,
54 290
                    true
55
                )
56
            ),
57 290
            new AnnotationMetadata(
58 290
                Enum::class,
59 290
                AnnotationTarget::property(),
60 290
                true,
61 290
                new PropertyMetadata(
62 290
                    'value',
63 290
                    ['type' => 'array'],
64 290
                    true,
65 290
                    true
66
                ),
67 290
                new PropertyMetadata(
68 290
                    'literal',
69 290
                    ['type' => 'array']
70
                )
71
            ),
72 290
            new AnnotationMetadata(
73 290
                Target::class,
74 290
                AnnotationTarget::class(),
75 290
                true,
76 290
                new PropertyMetadata(
77 290
                    'value',
78
                    [
79 290
                        'type'      =>'array',
80
                        'array_type'=>'string',
81
                        'value'     =>'array<string>',
82
                    ],
83 290
                    false,
84 290
                    true
85
                )
86
            )
87
        );
88
    }
89
}
90