| Conditions | 10 |
| Paths | 10 |
| Total Lines | 62 |
| Code Lines | 37 |
| 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 |
||
| 37 | public function readArguments(array $args, array $message) |
||
| 38 | { |
||
| 39 | $envelope = array_filter($args, function ($item) use ($message) { |
||
| 40 | return $item instanceof $message['message_fqcn']; |
||
| 41 | }); |
||
| 42 | if ($envelope) { |
||
| 43 | return reset($envelope); |
||
| 44 | } |
||
| 45 | |||
| 46 | $instantiator = new Instantiator(); |
||
| 47 | $envelope = $instantiator->instantiate($message['message_fqcn']); |
||
| 48 | |||
| 49 | if (!count($message['parts'])) { |
||
| 50 | return $envelope; |
||
| 51 | } |
||
| 52 | |||
| 53 | $args = $this->handleHeaders($args, $message, $envelope); |
||
| 54 | if ($args[0] instanceof $message['part_fqcn']) { |
||
| 55 | $envelope->setBody($args[0]); |
||
| 56 | return $envelope; |
||
| 57 | } |
||
| 58 | |||
| 59 | $body = $instantiator->instantiate($message['part_fqcn']); |
||
| 60 | $envelope->setBody($body); |
||
| 61 | |||
| 62 | $factory = SerializerUtils::getMetadataFactory($this->serializer); |
||
| 63 | |||
| 64 | $classMetadata = $factory->getMetadataForClass($message['part_fqcn']); |
||
| 65 | |||
| 66 | if (count($message['parts']) > 1) { |
||
| 67 | |||
| 68 | if (count($message['parts']) !== count($args)) { |
||
| 69 | throw new \Exception("Expected to have exactly " . count($message['parts']) . " arguments, supplied " . count($args)); |
||
| 70 | } |
||
| 71 | |||
| 72 | foreach ($message['parts'] as $paramName => $elementName) { |
||
| 73 | $propertyMetadata = $classMetadata->propertyMetadata[$paramName]; |
||
| 74 | $this->setValue($body, array_shift($args), $propertyMetadata); |
||
| 75 | } |
||
| 76 | return $envelope; |
||
| 77 | } |
||
| 78 | |||
| 79 | $propertyName = key($message['parts']); |
||
| 80 | $propertyMetadata = $classMetadata->propertyMetadata[$propertyName]; |
||
| 81 | |||
| 82 | if ($args[0] instanceof $propertyMetadata->type['name']) { |
||
| 83 | $this->setValue($body, reset($args), $propertyMetadata); |
||
| 84 | return $envelope; |
||
| 85 | } |
||
| 86 | |||
| 87 | $instance2 = $instantiator->instantiate($propertyMetadata->type['name']); |
||
| 88 | $classMetadata2 = $factory->getMetadataForClass($propertyMetadata->type['name']); |
||
| 89 | $this->setValue($body, $instance2, $propertyMetadata); |
||
| 90 | |||
| 91 | foreach ($classMetadata2->propertyMetadata as $propertyMetadata2) { |
||
| 92 | if (!count($args)) { |
||
| 93 | throw new \Exception("Not enough arguments provided. Can't find a parameter to set " . $propertyMetadata2->name); |
||
| 94 | } |
||
| 95 | $value = array_shift($args); |
||
| 96 | $this->setValue($instance2, $value, $propertyMetadata2); |
||
| 97 | } |
||
| 98 | return $envelope; |
||
| 99 | } |
||
| 150 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths