Skip to content

Commit

Permalink
- Use array_map() instead of loops.
Browse files Browse the repository at this point in the history
# Patch by Hubert Roksor.
  • Loading branch information
sebastianbergmann committed Nov 11, 2007
1 parent 8e6ea00 commit 9a5135b
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions PHPUnit/Util/Report/Node/File.php
Expand Up @@ -646,17 +646,12 @@ protected function calculateStatistics()
*/
protected function loadFile($file)
{
$lines = file($file);
$numLines = count($lines);
$width = 0;
$lines = array_map('rtrim', file($file));
$linesLength = array_map('strlen', $lines);
$width = max($linesLength);

for ($i = 0; $i < $numLines; $i++) {
$lines[$i] = rtrim($lines[$i]);
$width = max($width, strlen($lines[$i]));
}

for ($i = 0; $i < $numLines; $i++) {
$this->codeLinesFillup[$i] = $width - strlen($lines[$i]);
foreach ($linesLength as $line => $length) {
$this->codeLinesFillup[$line] = $width - $length;
}

if (!$this->highlight) {
Expand Down

0 comments on commit 9a5135b

Please sign in to comment.