* @since 2.0
 */
class DiffRendererHtmlInline extends \Diff_Renderer_Html_Array
{
    /**
     * Render a and return diff with changes between the two sequences
     * displayed inline (under each other)
     *
     * @return string The generated inline diff.
     */
    public function render()
    {
        $changes = parent::render();
        $html = '';
        if (empty($changes)) {
            return $html;
        }
        $html .= <<
    
        
            | Old | New | Differences | 
    
HTML;
        foreach ($changes as $i => $blocks) {
            // If this is a separate block, we're condensing code so output ...,
            // indicating a significant portion of the code has been collapsed as
            // it is the same
            if ($i > 0) {
                $html .= <<
        
 |  | HTML;
            }
            foreach ($blocks as $change) {
                $tag = ucfirst($change['tag']);
                $html .= <<
HTML;
                // Equal changes should be shown on both sides of the diff
                if ($change['tag'] === 'equal') {
                    foreach ($change['base']['lines'] as $no => $line) {
                        $fromLine = $change['base']['offset'] + $no + 1;
                        $toLine = $change['changed']['offset'] + $no + 1;
                        $html .= << |  |  | {$line}HTML;
                    }
                }
                // Added lines only on the right side
                elseif ($change['tag'] === 'insert') {
                    foreach ($change['changed']['lines'] as $no => $line) {
                        $toLine = $change['changed']['offset'] + $no + 1;
                        $html .= << |  |  | {$line}HTML;
                    }
                }
                // Show deleted lines only on the left side
                elseif ($change['tag'] === 'delete') {
                    foreach ($change['base']['lines'] as $no => $line) {
                        $fromLine = $change['base']['offset'] + $no + 1;
                        $html .= << |  |  | HTML;
                    }
                }
                // Show modified lines on both sides
                elseif ($change['tag'] === 'replace') {
                    foreach ($change['base']['lines'] as $no => $line) {
                        $fromLine = $change['base']['offset'] + $no + 1;
                        $html .= <<{$line} |  |  | {$line}HTML;
                    }
                    foreach ($change['changed']['lines'] as $no => $line) {
                        $toLine = $change['changed']['offset'] + $no + 1;
                        $html .= << |  |  | {$line}HTML;
                    }
                }
                $html .= <<
HTML;
            }
        }
        $html .= <<
HTML;
        return $html;
    }
} |