Conditions | 11 |
Paths | 58 |
Total Lines | 41 |
Code Lines | 21 |
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 |
||
75 | public function resolveRequest() { |
||
76 | $output = []; |
||
77 | |||
78 | if (!$this->executionContext->hasErrors()) { |
||
79 | try { |
||
80 | $operations = $this->executionContext->getRequest()->getAllOperations(); |
||
81 | |||
82 | foreach ($operations as $query) { |
||
83 | if ($result = $this->resolveQuery($query)) { |
||
84 | $output = array_replace_recursive($output, $result); |
||
85 | }; |
||
86 | } |
||
87 | |||
88 | // If the processor found any deferred results, resolve them now. |
||
89 | if (!empty($output) && (!empty($this->deferredResultsLeaf) || !empty($this->deferredResultsComplex))) { |
||
90 | try { |
||
91 | while ($resolver = array_shift($this->deferredResultsComplex)) { |
||
92 | $resolver->resolve(); |
||
93 | } |
||
94 | |||
95 | // Deferred scalar and enum fields should be resolved last to pick up |
||
96 | // as many as possible for a single batch. |
||
97 | while ($resolver = array_shift($this->deferredResultsLeaf)) { |
||
98 | $resolver->resolve(); |
||
99 | } |
||
100 | } |
||
101 | catch (ResolveException $exception) { |
||
102 | $this->executionContext->addError($exception); |
||
103 | } |
||
104 | finally { |
||
105 | $output = static::unpackDeferredResults($output); |
||
106 | } |
||
107 | } |
||
108 | } |
||
109 | catch (ResolveException $exception) { |
||
110 | $this->executionContext->addError($exception); |
||
111 | } |
||
112 | } |
||
113 | |||
114 | return $output; |
||
115 | } |
||
116 | |||
144 | } |