| Conditions | 9 |
| Paths | 256 |
| Total Lines | 58 |
| Code Lines | 38 |
| 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 |
||
| 57 | public function resolve($args) |
||
| 58 | { |
||
| 59 | if (!isset($args['title'])) { |
||
| 60 | $args['title'] = null; |
||
| 61 | } |
||
| 62 | if (!isset($args['projectId'])) { |
||
| 63 | $args['projectId'] = null; |
||
| 64 | } |
||
| 65 | if (!isset($args['parentId'])) { |
||
| 66 | $args['parentId'] = null; |
||
| 67 | } |
||
| 68 | if (!isset($args['priority'])) { |
||
| 69 | $args['priority'] = null; |
||
| 70 | } |
||
| 71 | if (!isset($args['progress'])) { |
||
| 72 | $args['progress'] = null; |
||
| 73 | } |
||
| 74 | if (!isset($args['assigneeId'])) { |
||
| 75 | $args['assigneeId'] = null; |
||
| 76 | } |
||
| 77 | if (!isset($args['creatorId'])) { |
||
| 78 | $args['creatorId'] = null; |
||
| 79 | } |
||
| 80 | |||
| 81 | list($offset, $limit, $total) = $this->buildPagination($args); |
||
| 82 | |||
| 83 | $this->queryBus->handle( |
||
| 84 | new FilterTasksQuery( |
||
| 85 | $this->currentUser, |
||
| 86 | $offset, |
||
| 87 | $limit, |
||
| 88 | $args['parentId'], |
||
| 89 | $args['projectId'], |
||
| 90 | $args['title'], |
||
| 91 | $args['priority'], |
||
| 92 | $args['progress'], |
||
| 93 | $args['assigneeId'], |
||
| 94 | $args['creatorId'] |
||
| 95 | ), |
||
| 96 | $result |
||
| 97 | ); |
||
| 98 | |||
| 99 | foreach ($result as $key => $task) { |
||
| 100 | $result[$key] = $this->taskBuilderResolver->resolve($task); |
||
| 101 | } |
||
| 102 | |||
| 103 | $connection = $this->connectionBuilder->fromArraySlice( |
||
| 104 | $result, |
||
| 105 | $args, |
||
| 106 | [ |
||
| 107 | 'sliceStart' => $offset, |
||
| 108 | 'arrayLength' => $total, |
||
| 109 | ] |
||
| 110 | ); |
||
| 111 | $connection->totalCount = count($result); |
||
| 112 | |||
| 113 | return $connection; |
||
| 114 | } |
||
| 115 | |||
| 163 |
Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a
@returnannotation as described here.