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