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