| Conditions | 15 |
| Paths | 56 |
| Total Lines | 107 |
| Code Lines | 54 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | 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 |
||
| 97 | public function writeFinalReport($duration, $summary) |
||
| 98 | { |
||
| 99 | // keep count of what the final results are |
||
| 100 | $succeededGroups = []; |
||
| 101 | $skippedGroups = []; |
||
| 102 | $failedGroups = []; |
||
| 103 | |||
| 104 | // do we have any results? |
||
| 105 | if (!isset($this->results)) { |
||
| 106 | // huh - nothing happened at all |
||
| 107 | $this->write("HUH - nothing appears to have happened. Time taken: ", $this->writer->puzzledSummaryStyle); |
||
| 108 | $this->writeDuration($duration, $this->writer->puzzledSummaryStyle); |
||
| 109 | $this->write(PHP_EOL . PHP_EOL); |
||
| 110 | return; |
||
| 111 | } |
||
| 112 | |||
| 113 | // this is our opportunity to tell the user how our story(ies) |
||
| 114 | // went in detail |
||
| 115 | foreach ($this->results as $result) |
||
| 116 | { |
||
| 117 | // so what happened? |
||
| 118 | switch ($result->resultCode) |
||
| 119 | { |
||
| 120 | case PhaseGroup_Result::OKAY: |
||
| 121 | // this is a good result |
||
| 122 | $succeededGroups[] = $result; |
||
| 123 | break; |
||
| 124 | |||
| 125 | case PhaseGroup_Result::SKIPPED: |
||
| 126 | case PhaseGroup_Result::BLACKLISTED: |
||
| 127 | // this can legitimately happen |
||
| 128 | $skippedGroups[] = $result; |
||
| 129 | break; |
||
| 130 | |||
| 131 | default: |
||
| 132 | // everything else is an error of some kind |
||
| 133 | $failedGroups[] = $result; |
||
| 134 | } |
||
| 135 | } |
||
| 136 | |||
| 137 | // what's the final tally? |
||
| 138 | $this->write(PHP_EOL); |
||
| 139 | if (empty($succeededGroups) && empty($skippedGroups) && empty($failedGroups)) { |
||
| 140 | // huh - nothing happened at all |
||
| 141 | $this->write("HUH - nothing appears to have happened. Time taken: ", $this->writer->puzzledSummaryStyle); |
||
| 142 | $this->writeDuration($duration, $this->writer->puzzledSummaryStyle); |
||
| 143 | $this->write(PHP_EOL . PHP_EOL); |
||
| 144 | return; |
||
| 145 | } |
||
| 146 | if (empty($failedGroups)) { |
||
| 147 | // nothing failed |
||
| 148 | $this->write("SUCCESS - " . count($succeededGroups) . ' PASSED, ' . count($skippedGroups) . ' SKIPPED. Time taken: ', $this->writer->successSummaryStyle); |
||
| 149 | $this->writeDuration($duration, $this->writer->successSummaryStyle); |
||
| 150 | $this->write(PHP_EOL . PHP_EOL); |
||
| 151 | return; |
||
| 152 | } |
||
| 153 | |||
| 154 | // if we get here, then at least one thing failed |
||
| 155 | $this->write("FAILURE - " |
||
| 156 | . count($succeededGroups) . ' PASSED, ' |
||
| 157 | . count($skippedGroups) . ' SKIPPED, ' |
||
| 158 | . count($failedGroups) . ' FAILED :( Time taken: ', |
||
| 159 | $this->writer->failSummaryStyle); |
||
| 160 | $this->writeDuration($duration, $this->writer->failSummaryStyle); |
||
| 161 | $this->write(PHP_EOL . PHP_EOL); |
||
| 162 | |||
| 163 | // write out a list of failed tests - someone will want to look |
||
| 164 | // at them in detail |
||
| 165 | $this->write("Here's the list of everything that failed:" . PHP_EOL . PHP_EOL); |
||
| 166 | // foreach ($skippedGroups as $skippedGroup) { |
||
| 167 | // $this->writePhaseGroupSkipped(); |
||
| 168 | // $this->write(' ' . $skippedGroup->activity, $this->writer->activityStyle); |
||
| 169 | // $this->write(' ' . $skippedGroup->name . PHP_EOL, $this->writer->nameStyle); |
||
| 170 | |||
| 171 | // if (isset($skippedGroup->filename)) { |
||
| 172 | // $this->write(' (', $this->writer->punctuationStyle); |
||
| 173 | // $this->write($skippedGroup->filename, $this->writer->punctuationStyle); |
||
| 174 | // $this->write(')' . PHP_EOL, $this->writer->punctuationStyle); |
||
| 175 | // } |
||
| 176 | // } |
||
| 177 | foreach ($failedGroups as $failedGroup) { |
||
| 178 | $this->writePhaseGroupFailed(); |
||
| 179 | $this->write(' ' . $failedGroup->activity, $this->writer->activityStyle); |
||
| 180 | $this->write(' ' . $failedGroup->name . PHP_EOL, $this->writer->nameStyle); |
||
| 181 | |||
| 182 | if (isset($failedGroup->filename)) { |
||
| 183 | $this->write(' (', $this->writer->punctuationStyle); |
||
| 184 | $this->write($failedGroup->filename, $this->writer->punctuationStyle); |
||
| 185 | $this->write(')' . PHP_EOL, $this->writer->punctuationStyle); |
||
| 186 | } |
||
| 187 | } |
||
| 188 | $this->write(PHP_EOL); |
||
| 189 | |||
| 190 | // do we stop here? |
||
| 191 | if (!$summary) { |
||
| 192 | // we're in dev mode, which means the error reports have |
||
| 193 | // already been shown where they happened |
||
| 194 | return; |
||
| 195 | } |
||
| 196 | |||
| 197 | // are we being run by hand? |
||
| 198 | if (function_exists("posix_isatty") && posix_isatty(STDOUT)) { |
||
| 199 | $this->write("See "); |
||
| 200 | $this->write("storyplayer.log", $this->writer->argStyle); |
||
| 201 | $this->write(" for details on what went wrong." . PHP_EOL . PHP_EOL); |
||
| 202 | } |
||
| 203 | } |
||
| 204 | |||
| 344 | } |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.