| Conditions | 12 |
| Paths | 25 |
| Total Lines | 42 |
| Code Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 32 |
| CRAP Score | 12 |
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 |
||
| 64 | 299 | public function resolveReferences(stdClass $schema, Uri $uri) |
|
| 65 | { |
||
| 66 | 299 | if ($this->isLooping($schema, $this->resolvedSchemas)) { |
|
| 67 | 20 | return $schema; |
|
| 68 | } |
||
| 69 | |||
| 70 | 299 | if (!$this->resolver->hasBaseSchema()) { |
|
| 71 | 299 | $this->resolver->setBaseSchema($schema, $uri); |
|
| 72 | 299 | } |
|
| 73 | |||
| 74 | 299 | $inScope = false; |
|
| 75 | |||
| 76 | 299 | if (property_exists($schema, 'id') && is_string($schema->id)) { |
|
| 77 | 7 | $this->resolver->enter(new Uri($schema->id)); |
|
| 78 | 7 | $inScope = true; |
|
| 79 | 7 | } |
|
| 80 | |||
| 81 | 299 | if (property_exists($schema, '$ref')) { |
|
| 82 | 22 | $resolved = $this->resolver->resolve($schema); |
|
| 83 | 22 | $this->resolver->enter($resolved[0], $resolved[1]); |
|
| 84 | 22 | $schema = $this->resolveReferences($resolved[1], $resolved[0]); |
|
| 85 | 22 | $this->resolver->leave(); |
|
| 86 | 22 | } else { |
|
| 87 | 299 | foreach ($schema as $property => $value) { |
|
| 88 | 299 | if (is_object($value)) { |
|
| 89 | 114 | $schema->{$property} = $this->resolveReferences($value, $uri); |
|
| 90 | 299 | } elseif (is_array($value)) { |
|
| 91 | 75 | foreach ($value as $index => $element) { |
|
| 92 | 73 | if (is_object($element)) { |
|
| 93 | 44 | $schema->{$property}[$index] = $this->resolveReferences($element, $uri); |
|
| 94 | 44 | } |
|
| 95 | 75 | } |
|
| 96 | 75 | } |
|
| 97 | 299 | } |
|
| 98 | } |
||
| 99 | |||
| 100 | 299 | if ($inScope) { |
|
| 101 | 7 | $this->resolver->leave(); |
|
| 102 | 7 | } |
|
| 103 | |||
| 104 | 299 | return $schema; |
|
| 105 | } |
||
| 106 | |||
| 184 |