Conditions | 1 |
Paths | 1 |
Total Lines | 55 |
Code Lines | 45 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
35 | public static function fromXML(DOMElement $xml): static |
||
36 | { |
||
37 | Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
||
38 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
39 | |||
40 | $annotation = Annotation::getChildrenOfClass($xml); |
||
41 | Assert::maxCount($annotation, 1, TooManyElementsException::class); |
||
42 | |||
43 | $localAttribute = LocalAttribute::getChildrenOfClass($xml); |
||
44 | $attributeGroup = ReferencedAttributeGroup::getChildrenOfClass($xml); |
||
45 | $attributes = array_merge($localAttribute, $attributeGroup); |
||
46 | |||
47 | $anyAttribute = AnyAttribute::getChildrenOfClass($xml); |
||
48 | Assert::maxCount($anyAttribute, 1, TooManyElementsException::class); |
||
49 | |||
50 | $localSimpleType = LocalSimpleType::getChildrenOfClass($xml); |
||
51 | Assert::maxCount($localSimpleType, 1, TooManyElementsException::class); |
||
52 | |||
53 | $minExclusive = MinExclusive::getChildrenOfClass($xml); |
||
54 | $minInclusive = MinInclusive::getChildrenOfClass($xml); |
||
55 | $maxExclusive = MaxExclusive::getChildrenOfClass($xml); |
||
56 | $maxInclusive = MaxInclusive::getChildrenOfClass($xml); |
||
57 | $totalDigits = TotalDigits::getChildrenOfClass($xml); |
||
58 | $fractionDigits = FractionDigits::getChildrenOfClass($xml); |
||
59 | $length = Length::getChildrenOfClass($xml); |
||
60 | $minLength = MinLength::getChildrenOfClass($xml); |
||
61 | $maxLength = MaxLength::getChildrenOfClass($xml); |
||
62 | $enumeration = Enumeration::getChildrenOfClass($xml); |
||
63 | $whiteSpace = WhiteSpace::getChildrenOfClass($xml); |
||
64 | $pattern = Pattern::getChildrenOfClass($xml); |
||
65 | |||
66 | $facets = array_merge( |
||
67 | $maxExclusive, |
||
68 | $maxInclusive, |
||
69 | $minExclusive, |
||
70 | $minInclusive, |
||
71 | $totalDigits, |
||
72 | $fractionDigits, |
||
73 | $length, |
||
74 | $maxLength, |
||
75 | $minLength, |
||
76 | $enumeration, |
||
77 | $whiteSpace, |
||
78 | $pattern, |
||
79 | ); |
||
80 | |||
81 | return new static( |
||
82 | self::getAttribute($xml, 'base', QNameValue::class), |
||
83 | array_pop($localSimpleType), |
||
84 | $facets, |
||
85 | $attributes, |
||
86 | array_pop($anyAttribute), |
||
87 | array_pop($annotation), |
||
88 | self::getOptionalAttribute($xml, 'id', IDValue::class, null), |
||
89 | self::getAttributesNSFromXML($xml), |
||
90 | ); |
||
93 |