| Conditions | 6 |
| Paths | 7 |
| Total Lines | 59 |
| Code Lines | 37 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 34 | public function resolve($object, array $args, $context, ResolveInfo $info) |
||
| 35 | { |
||
| 36 | $block = BaseElement::get_by_id($args['ID']); |
||
| 37 | |||
| 38 | if (!$block) { |
||
| 39 | throw new \InvalidArgumentException(sprintf( |
||
| 40 | '%s# not found', |
||
| 41 | ElementArea::class, |
||
| 42 | $args['ID'] |
||
| 43 | )); |
||
| 44 | } |
||
| 45 | |||
| 46 | $parentId = $block->ParentID; |
||
| 47 | $blockPosition = $block->Sort; |
||
| 48 | |||
| 49 | $sortAfterPosition = 0; |
||
| 50 | $afterBlockID = $args['AfterBlockID']; |
||
| 51 | if ($afterBlockID) { |
||
| 52 | $afterBlock = BaseElement::get_by_id($afterBlockID); |
||
| 53 | |||
| 54 | if (!$afterBlock) { |
||
| 55 | throw new \InvalidArgumentException(sprintf( |
||
| 56 | '%s#%s not found', |
||
| 57 | BaseElement::class, |
||
| 58 | $afterBlockID |
||
| 59 | )); |
||
| 60 | } |
||
| 61 | if ($afterBlock->ParentID !== $parentId) { |
||
| 62 | throw new \InvalidArgumentException(sprintf( |
||
| 63 | '%s# not found', |
||
| 64 | BaseElement::class, |
||
| 65 | $parentId |
||
| 66 | )); |
||
| 67 | } |
||
| 68 | |||
| 69 | $sortAfterPosition = $afterBlock->Sort; |
||
| 70 | } |
||
| 71 | |||
| 72 | if ($sortAfterPosition < $blockPosition) { |
||
| 73 | $operator = '+'; |
||
| 74 | $filter = "Sort > $sortAfterPosition && Sort < $blockPosition"; |
||
| 75 | $newBlockPosition = $sortAfterPosition + 1; |
||
| 76 | } |
||
| 77 | else { |
||
| 78 | $operator = '-'; |
||
| 79 | $filter = "Sort <= $sortAfterPosition && Sort > $blockPosition"; |
||
| 80 | $newBlockPosition = $sortAfterPosition; |
||
| 81 | } |
||
| 82 | |||
| 83 | DB::query(" |
||
| 84 | UPDATE Element |
||
| 85 | SET Sort = (Sort $operator 1) |
||
| 86 | WHERE $filter && ParentId = $parentId |
||
| 87 | "); |
||
| 88 | |||
| 89 | $block->Sort = $newBlockPosition; |
||
| 90 | $block->write(); |
||
| 91 | |||
| 92 | return $block; |
||
| 93 | } |
||
| 95 |
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