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