Conditions | 1 |
Paths | 1 |
Total Lines | 66 |
Code Lines | 51 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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 | ) |
||
88 |