| Conditions | 1 |
| Paths | 1 |
| Total Lines | 53 |
| Code Lines | 37 |
| 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 |
||
| 48 | { |
||
| 49 | Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); |
||
| 50 | Assert::same($xml->namespaceURI, static::NS, InvalidDOMElementException::class); |
||
| 51 | |||
| 52 | // Prohibited attributes |
||
| 53 | $ref = self::getOptionalAttribute($xml, 'ref', QNameValue::class, null); |
||
| 54 | Assert::null($ref, SchemaViolationException::class); |
||
| 55 | |||
| 56 | $form = self::getOptionalAttribute($xml, 'form', FormChoiceValue::class, null); |
||
| 57 | Assert::null($form, SchemaViolationException::class); |
||
| 58 | |||
| 59 | $minCount = self::getOptionalAttribute($xml, 'minCount', MinOccursValue::class, null); |
||
| 60 | Assert::null($minCount, SchemaViolationException::class); |
||
| 61 | |||
| 62 | $maxCount = self::getOptionalAttribute($xml, 'maxCount', MaxOccursValue::class, null); |
||
| 63 | Assert::null($maxCount, SchemaViolationException::class); |
||
| 64 | |||
| 65 | // The annotation |
||
| 66 | $annotation = Annotation::getChildrenOfClass($xml); |
||
| 67 | Assert::maxCount($annotation, 1, TooManyElementsException::class); |
||
| 68 | |||
| 69 | // The local type |
||
| 70 | $localSimpleType = LocalSimpleType::getChildrenOfClass($xml); |
||
| 71 | Assert::maxCount($localSimpleType, 1, TooManyElementsException::class); |
||
| 72 | |||
| 73 | $localComplexType = LocalComplexType::getChildrenOfClass($xml); |
||
| 74 | Assert::maxCount($localComplexType, 1, TooManyElementsException::class); |
||
| 75 | |||
| 76 | $localType = array_merge($localSimpleType, $localComplexType); |
||
| 77 | Assert::maxCount($localType, 1, TooManyElementsException::class); |
||
| 78 | |||
| 79 | // The identity constraint |
||
| 80 | $key = Key::getChildrenOfClass($xml); |
||
| 81 | $keyref = Keyref::getChildrenOfClass($xml); |
||
| 82 | $unique = Unique::getChildrenOfClass($xml); |
||
| 83 | $identityConstraint = array_merge($key, $keyref, $unique); |
||
| 84 | |||
| 85 | return new static( |
||
| 86 | self::getAttribute($xml, 'name', NCNameValue::class), |
||
| 87 | array_pop($localType), |
||
| 88 | $identityConstraint, |
||
| 89 | self::getOptionalAttribute($xml, 'type', QNameValue::class, null), |
||
| 90 | self::getOptionalAttribute($xml, 'substitutionGroup', QNameValue::class, null), |
||
| 91 | self::getOptionalAttribute($xml, 'default', StringValue::class, null), |
||
| 92 | self::getOptionalAttribute($xml, 'fixed', StringValue::class, null), |
||
| 93 | self::getOptionalAttribute($xml, 'nillable', BooleanValue::class, null), |
||
| 94 | self::getOptionalAttribute($xml, 'abstract', BooleanValue::class, null), |
||
| 95 | self::getOptionalAttribute($xml, 'final', DerivationSetValue::class, null), |
||
| 96 | self::getOptionalAttribute($xml, 'block', BlockSetValue::class, null), |
||
| 97 | array_pop($annotation), |
||
| 98 | self::getOptionalAttribute($xml, 'id', IDValue::class, null), |
||
| 99 | self::getAttributesNSFromXML($xml), |
||
| 100 | ); |
||
| 101 | } |
||
| 103 |