| Conditions | 1 |
| Paths | 1 |
| Total Lines | 52 |
| Code Lines | 38 |
| 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 |
||
| 47 | { |
||
| 48 | Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
||
| 49 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
| 50 | |||
| 51 | $annotation = Annotation::getChildrenOfClass($xml); |
||
| 52 | Assert::maxCount($annotation, 1, TooManyElementsException::class); |
||
| 53 | |||
| 54 | $simpleContent = SimpleContent::getChildrenOfClass($xml); |
||
| 55 | Assert::maxCount($simpleContent, 1, TooManyElementsException::class); |
||
| 56 | |||
| 57 | $complexContent = ComplexContent::getChildrenOfClass($xml); |
||
| 58 | Assert::maxCount($complexContent, 1, TooManyElementsException::class); |
||
| 59 | |||
| 60 | $content = array_merge($simpleContent, $complexContent); |
||
| 61 | Assert::maxCount($content, 1, TooManyElementsException::class); |
||
| 62 | |||
| 63 | $referencedGroup = ReferencedGroup::getChildrenOfClass($xml); |
||
| 64 | Assert::maxCount($referencedGroup, 1, TooManyElementsException::class); |
||
| 65 | |||
| 66 | $all = All::getChildrenOfClass($xml); |
||
| 67 | Assert::maxCount($all, 1, TooManyElementsException::class); |
||
| 68 | |||
| 69 | $choice = Choice::getChildrenOfClass($xml); |
||
| 70 | Assert::maxCount($choice, 1, TooManyElementsException::class); |
||
| 71 | |||
| 72 | $sequence = Sequence::getChildrenOfClass($xml); |
||
| 73 | Assert::maxCount($sequence, 1, TooManyElementsException::class); |
||
| 74 | |||
| 75 | $particles = array_merge($referencedGroup, $all, $choice, $sequence); |
||
| 76 | Assert::maxCount($particles, 1, TooManyElementsException::class); |
||
| 77 | |||
| 78 | $localAttribute = LocalAttribute::getChildrenOfClass($xml); |
||
| 79 | $referencedAttributeGroup = ReferencedAttributeGroup::getChildrenOfClass($xml); |
||
| 80 | $attributes = array_merge($localAttribute, $referencedAttributeGroup); |
||
| 81 | |||
| 82 | $anyAttribute = AnyAttribute::getChildrenOfClass($xml); |
||
| 83 | Assert::maxCount($anyAttribute, 1, TooManyElementsException::class); |
||
| 84 | |||
| 85 | return new static( |
||
| 86 | self::getAttribute($xml, 'name', NCNameValue::class), |
||
| 87 | self::getOptionalAttribute($xml, 'mixed', BooleanValue::class, null), |
||
| 88 | self::getOptionalAttribute($xml, 'abstract', BooleanValue::class, null), |
||
| 89 | self::getOptionalAttribute($xml, 'final', DerivationSetValue::class, null), |
||
| 90 | self::getOptionalAttribute($xml, 'block', DerivationSetValue::class, null), |
||
| 91 | array_pop($content), |
||
| 92 | array_pop($particles), |
||
| 93 | $attributes, |
||
| 94 | array_pop($anyAttribute), |
||
| 95 | array_pop($annotation), |
||
| 96 | self::getOptionalAttribute($xml, 'id', IDValue::class, null), |
||
| 97 | self::getAttributesNSFromXML($xml), |
||
| 98 | ); |
||
| 99 | } |
||
| 101 |