| Conditions | 13 |
| Paths | 7 |
| Total Lines | 41 |
| Code Lines | 21 |
| 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 |
||
| 30 | public function FindVocabularyAnnotations( |
||
| 31 | IVocabularyAnnotatable $element, |
||
| 32 | $term = null, |
||
| 33 | string $qualifier = null, |
||
| 34 | string $type = null |
||
| 35 | ): iterable { |
||
| 36 | assert( |
||
| 37 | null === $term || $term instanceof ITerm || is_string($term), |
||
| 38 | '$term should be a string or instanceof iTerm' |
||
| 39 | ); |
||
| 40 | if (null === $term) { |
||
| 41 | return $this->processNullVocabularyAnnotationTerm($element); |
||
| 42 | } |
||
| 43 | if (is_string($term)) { |
||
| 44 | $termName = $term; |
||
| 45 | // Look up annotations on the element by name. There's no particular advantage in searching for a term first. |
||
| 46 | $name = null; |
||
| 47 | $namespaceName = null; |
||
| 48 | |||
| 49 | if (EdmUtil::TryGetNamespaceNameFromQualifiedName($termName, $namespaceName, $name)) { |
||
| 50 | /** |
||
| 51 | * @var IVocabularyAnnotation $annotation |
||
| 52 | */ |
||
| 53 | foreach ($this->FindVocabularyAnnotations($element) as $annotation) { |
||
| 54 | if (null !== $type && !is_a($annotation, $type)) { |
||
| 55 | continue; |
||
| 56 | } |
||
| 57 | $annotationTerm = $annotation->getTerm(); |
||
| 58 | if ($annotationTerm->getNamespace() === $namespaceName && |
||
| 59 | $annotationTerm->getName() === $name && |
||
| 60 | ( |
||
| 61 | null === $qualifier || |
||
| 62 | $qualifier == $annotation->getQualifier() |
||
| 63 | ) |
||
| 64 | ) { |
||
| 65 | yield $annotation; |
||
|
|
|||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 | } else { |
||
| 70 | return $this->processTermVocabularyAnnotationTerm($element, $term, $qualifier, $type); |
||
| 71 | } |
||
| 156 |