| Conditions | 10 |
| Paths | 512 |
| Total Lines | 62 |
| Code Lines | 40 |
| 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 |
||
| 57 | public function resolve($args) |
||
| 58 | { |
||
| 59 | if (isset($args['taskConnectionInput'])) { |
||
| 60 | $args = $args['taskConnectionInput']; |
||
| 61 | } |
||
| 62 | |||
| 63 | if (!isset($args['title'])) { |
||
| 64 | $args['title'] = null; |
||
| 65 | } |
||
| 66 | if (!isset($args['projectId'])) { |
||
| 67 | $args['projectId'] = null; |
||
| 68 | } |
||
| 69 | if (!isset($args['parentId'])) { |
||
| 70 | $args['parentId'] = null; |
||
| 71 | } |
||
| 72 | if (!isset($args['priority'])) { |
||
| 73 | $args['priority'] = null; |
||
| 74 | } |
||
| 75 | if (!isset($args['progress'])) { |
||
| 76 | $args['progress'] = null; |
||
| 77 | } |
||
| 78 | if (!isset($args['assigneeId'])) { |
||
| 79 | $args['assigneeId'] = null; |
||
| 80 | } |
||
| 81 | if (!isset($args['reporterId'])) { |
||
| 82 | $args['reporterId'] = null; |
||
| 83 | } |
||
| 84 | |||
| 85 | list($offset, $limit, $total) = $this->buildPagination($args); |
||
| 86 | |||
| 87 | $this->queryBus->handle( |
||
| 88 | new FilterTasksQuery( |
||
| 89 | $this->currentUser, |
||
| 90 | $offset, |
||
| 91 | $limit, |
||
| 92 | $args['parentId'], |
||
| 93 | $args['projectId'], |
||
| 94 | $args['title'], |
||
| 95 | $args['priority'], |
||
| 96 | $args['progress'], |
||
| 97 | $args['assigneeId'], |
||
| 98 | $args['reporterId'] |
||
| 99 | ), |
||
| 100 | $result |
||
| 101 | ); |
||
| 102 | |||
| 103 | foreach ($result as $key => $task) { |
||
| 104 | $result[$key] = $this->taskBuilderResolver->resolve($task); |
||
| 105 | } |
||
| 106 | |||
| 107 | $connection = $this->connectionBuilder->fromArraySlice( |
||
| 108 | $result, |
||
| 109 | $args, |
||
| 110 | [ |
||
| 111 | 'sliceStart' => $offset, |
||
| 112 | 'arrayLength' => $total, |
||
| 113 | ] |
||
| 114 | ); |
||
| 115 | $connection->totalCount = count($result); |
||
| 116 | |||
| 117 | return $connection; |
||
| 118 | } |
||
| 119 | |||
| 165 |
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.