| Conditions | 10 |
| Paths | 11 |
| Total Lines | 30 |
| Code Lines | 22 |
| 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 |
||
| 33 | public function getBackoffPeriod( |
||
| 34 | $retries, |
||
| 35 | RequestInterface $request, |
||
| 36 | Response $response = null, |
||
| 37 | HttpException $e = null |
||
| 38 | ) { |
||
| 39 | $delay = $this->getDelay($retries, $request, $response, $e); |
||
| 40 | if ($delay === false) { |
||
| 41 | // The strategy knows that this must not be retried |
||
| 42 | return false; |
||
| 43 | } elseif ($delay === null) { |
||
| 44 | // If the strategy is deferring a decision and the next strategy will not make a decision then return false |
||
| 45 | return !$this->next || !$this->next->makesDecision() |
||
| 46 | ? false |
||
| 47 | : $this->next->getBackoffPeriod($retries, $request, $response, $e); |
||
| 48 | } elseif ($delay === true) { |
||
| 49 | // if the strategy knows that it must retry but is deferring to the next to determine the delay |
||
| 50 | if (!$this->next) { |
||
| 51 | return 0; |
||
| 52 | } else { |
||
| 53 | $next = $this->next; |
||
| 54 | while ($next->makesDecision() && $next->getNext()) { |
||
| 55 | $next = $next->getNext(); |
||
| 56 | } |
||
| 57 | return !$next->makesDecision() ? $next->getBackoffPeriod($retries, $request, $response, $e) : 0; |
||
| 58 | } |
||
| 59 | } else { |
||
| 60 | return $delay; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | |||
| 92 |