| Conditions | 14 | 
| Paths | 15 | 
| Total Lines | 61 | 
| Code Lines | 28 | 
| 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 declare(strict_types=1);  | 
            ||
| 63 | public function debugAfter(GherkinNodeTested $event): void  | 
            ||
| 64 |     { | 
            ||
| 65 |         if (!$event instanceof AfterTested) { | 
            ||
| 66 | return;  | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 | // no http tag... still no chocolates  | 
            ||
| 70 |         if (!$this->hasTag($event, 'http')) { | 
            ||
| 71 | return;  | 
            ||
| 72 | }  | 
            ||
| 73 | |||
| 74 | // debug only if tag is present (all debug) or only on test failures  | 
            ||
| 75 |         if ($this->hasTag($event, 'debug')) { | 
            ||
| 76 | $tuples = current($this->history);  | 
            ||
| 77 | |||
| 78 |             foreach ($tuples as $tuple) { | 
            ||
| 79 |                 foreach ($tuple as list($request, $response)) { | 
            ||
| 80 | $this->debug($request, $response);  | 
            ||
| 81 | }  | 
            ||
| 82 | }  | 
            ||
| 83 | |||
| 84 | return;  | 
            ||
| 85 | }  | 
            ||
| 86 | |||
| 87 |         if (false === $this->configuration->getStatus()) { | 
            ||
| 88 | return;  | 
            ||
| 89 | }  | 
            ||
| 90 | |||
| 91 | $result = $event->getTestResult();  | 
            ||
| 92 | |||
| 93 |         if (TestResult::FAILED !== $result->getResultCode()) { | 
            ||
| 94 | return;  | 
            ||
| 95 | }  | 
            ||
| 96 | |||
| 97 | // all ->getTestResult() returns actually TestResults even for simple  | 
            ||
| 98 | // scenarios. So we have to ensure that if we are not testing against  | 
            ||
| 99 | // OutlineTested, we need to wrap the result in an array  | 
            ||
| 100 |         if ($result instanceof TestResults && !$event instanceof OutlineTested) { | 
            ||
| 101 | $result = [$result];  | 
            ||
| 102 | }  | 
            ||
| 103 | |||
| 104 | $values = iterator_to_array($this->history);  | 
            ||
| 105 | $key = -1;  | 
            ||
| 106 | |||
| 107 |         foreach ($result as $testResult) { | 
            ||
| 108 | ++$key;  | 
            ||
| 109 | |||
| 110 |             if (TestResult::FAILED !== $testResult->getResultCode()) { | 
            ||
| 111 | continue;  | 
            ||
| 112 | }  | 
            ||
| 113 | |||
| 114 | // no history created  | 
            ||
| 115 |             if (!isset($values[$key])) { | 
            ||
| 116 | continue;  | 
            ||
| 117 | }  | 
            ||
| 118 | |||
| 119 |             foreach ($values[$key] as list($request, $response)) { | 
            ||
| 120 | $this->debug($request, $response);  | 
            ||
| 121 | }  | 
            ||
| 122 | }  | 
            ||
| 123 | }  | 
            ||
| 124 | |||
| 176 |