| | if( $line === '' ) { |
| | $isMsg = true; |
| | - continue; |
| | - } |
| | - |
| | - if( $isMsg ) { |
| | + } elseif( $isMsg ) { |
| | $msg .= $line . "\n"; |
| | } else { |
 |
| | if( $hunkLine['t'] === '+' ) { |
| | $added++; |
| | - } |
| | - |
| | - if( $hunkLine['t'] === '-' ) { |
| | + } elseif( $hunkLine['t'] === '-' ) { |
| | $deleted++; |
| | } |
 |
| | $diffMsg = '0 lines changed'; |
| | $pluralize = function( int $count ): string { |
| | - $suffix = $count === 1 ? '' : 's'; |
| | + $suffix = ''; |
| | + |
| | + if( $count !== 1 ) { |
| | + $suffix = 's'; |
| | + } |
| | |
| | return $count . ' line' . $suffix; |
 |
| | } |
| | |
| | - private function renderFileDiff( $change ) { |
| | + private function renderFileDiff( array $change ) { |
| | $statusIcon = 'fa-file'; |
| | $statusClass = ''; |
| | |
| | if( $change['type'] === 'A' ) { |
| | $statusIcon = 'fa-plus-circle'; |
| | $statusClass = 'status-add'; |
| | - } |
| | - |
| | - if( $change['type'] === 'D' ) { |
| | + } elseif( $change['type'] === 'D' ) { |
| | $statusIcon = 'fa-minus-circle'; |
| | $statusClass = 'status-del'; |
| | - } |
| | - |
| | - if( $change['type'] === 'M' ) { |
| | + } elseif( $change['type'] === 'M' ) { |
| | $statusIcon = 'fa-pencil-alt'; |
| | $statusClass = 'status-mod'; |
 |
| | echo '<img src="/images/diff-gap.svg" class="diff-gap-icon" />'; |
| | echo '</td></tr>'; |
| | - continue; |
| | - } |
| | - |
| | - $class = 'diff-ctx'; |
| | - $char = ' '; |
| | + } else { |
| | + $class = 'diff-ctx'; |
| | + $char = ' '; |
| | |
| | - if( $line['t'] === '+' ) { |
| | - $class = 'diff-add'; |
| | - $char = '+'; |
| | - } |
| | + if( $line['t'] === '+' ) { |
| | + $class = 'diff-add'; |
| | + $char = '+'; |
| | + } elseif( $line['t'] === '-' ) { |
| | + $class = 'diff-del'; |
| | + $char = '-'; |
| | + } |
| | |
| | - if( $line['t'] === '-' ) { |
| | - $class = 'diff-del'; |
| | - $char = '-'; |
| | + echo '<tr class="' . $class . '">'; |
| | + echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>'; |
| | + echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>'; |
| | + echo '<td class="diff-code"><span class="diff-marker">' . |
| | + $char . '</span>' . htmlspecialchars( $line['l'] ) . '</td>'; |
| | + echo '</tr>'; |
| | } |
| | - |
| | - echo '<tr class="' . $class . '">'; |
| | - echo '<td class="diff-num" data-num="' . $line['no'] . '"></td>'; |
| | - echo '<td class="diff-num" data-num="' . $line['nn'] . '"></td>'; |
| | - echo '<td class="diff-code"><span class="diff-marker">' . |
| | - $char . '</span>' . htmlspecialchars( $line['l'] ) . '</td>'; |
| | - echo '</tr>'; |
| | } |
| | |