Failed Conditions
Push — new-parser-ast-metadata ( 6127e0...5a4a16 )
by Michael
12s
created

AnnotationWithVarTypeMetadata::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 55
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 55
rs 9.264
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\Tests\Annotations\Fixtures\Metadata;
6
7
use Doctrine\Annotations\Metadata\AnnotationMetadata;
8
use Doctrine\Annotations\Metadata\AnnotationTarget;
9
use Doctrine\Annotations\Metadata\PropertyMetadata;
10
use Doctrine\Annotations\Metadata\Type\BooleanType;
11
use Doctrine\Annotations\Metadata\Type\FloatType;
12
use Doctrine\Annotations\Metadata\Type\IntegerType;
13
use Doctrine\Annotations\Metadata\Type\ListType;
14
use Doctrine\Annotations\Metadata\Type\MapType;
15
use Doctrine\Annotations\Metadata\Type\MixedType;
16
use Doctrine\Annotations\Metadata\Type\ObjectType;
17
use Doctrine\Annotations\Metadata\Type\StringType;
18
use Doctrine\Annotations\Metadata\Type\UnionType;
19
use Doctrine\Tests\Annotations\Fixtures\AnnotationTargetAll;
20
use Doctrine\Tests\Annotations\Fixtures\AnnotationWithVarType;
21
22
final class AnnotationWithVarTypeMetadata
23
{
24
    public static function get(): AnnotationMetadata
25
    {
26
        return new AnnotationMetadata(
27
            AnnotationWithVarType::class,
28
            new AnnotationTarget(AnnotationTarget::TARGET_ALL),
29
            false,
30
            [
31
                new PropertyMetadata(
32
                    'mixed',
33
                    new MixedType(),
34
                    true
35
                ),
36
                new PropertyMetadata(
37
                    'boolean',
38
                    new BooleanType()
39
                ),
40
                new PropertyMetadata(
41
                    'bool',
42
                    new BooleanType()
43
                ),
44
                new PropertyMetadata(
45
                    'float',
46
                    new FloatType()
47
                ),
48
                new PropertyMetadata(
49
                    'string',
50
                    new StringType()
51
                ),
52
                new PropertyMetadata(
53
                    'integer',
54
                    new IntegerType()
55
                ),
56
                new PropertyMetadata(
57
                    'array',
58
                    new MapType(new UnionType(new IntegerType(), new StringType()), new MixedType())
59
                ),
60
                new PropertyMetadata(
61
                    'arrayMap',
62
                    new MapType(new StringType(), new MixedType())
63
                ),
64
                new PropertyMetadata(
65
                    'annotation',
66
                    new ObjectType(AnnotationTargetAll::class)
67
                ),
68
                new PropertyMetadata(
69
                    'arrayOfIntegers',
70
                    new ListType(new IntegerType())
71
                ),
72
                new PropertyMetadata(
73
                    'arrayOfStrings',
74
                    new ListType(new StringType())
75
                ),
76
                new PropertyMetadata(
77
                    'arrayOfAnnotations',
78
                    new ListType(new ObjectType(AnnotationTargetAll::class))
79
                ),
80
            ]
81
        );
82
    }
83
}
84