UnifiedDiffOutputBuilder
extends AbstractChunkOutputBuilder
in package
FinalYes
Builds a diff string representation in unified diff format in chunks.
Table of Contents
Properties
- $addLineNumbers : bool
- $collapseRanges : bool
- $commonLineThreshold : int
- $contextLines : int
- $header : string
Methods
- __construct() : mixed
- getDiff() : string
- getCommonChunks() : array<string|int, mixed>
- Takes input of the diff array and returns the common parts.
- writeDiffHunks() : void
- writeHunk() : void
Properties
$addLineNumbers
private
bool
$addLineNumbers
$collapseRanges
private
bool
$collapseRanges
= true
$commonLineThreshold
private
int
$commonLineThreshold
= 6
= 0
$contextLines
private
int
$contextLines
= 3
= 0
$header
private
string
$header
Methods
__construct()
public
__construct([string $header = "--- Original
+++ New
" ][, bool $addLineNumbers = false ]) : mixed
Parameters
- $header : string = "--- Original +++ New "
- $addLineNumbers : bool = false
getDiff()
public
getDiff(array<string|int, mixed> $diff) : string
Parameters
- $diff : array<string|int, mixed>
Return values
stringgetCommonChunks()
Takes input of the diff array and returns the common parts.
protected
getCommonChunks(array<string|int, mixed> $diff[, int $lineThreshold = 5 ]) : array<string|int, mixed>
Iterates through diff line by line.
Parameters
- $diff : array<string|int, mixed>
- $lineThreshold : int = 5
Return values
array<string|int, mixed>writeDiffHunks()
private
writeDiffHunks(mixed $output, array<string|int, mixed> $diff) : void
Parameters
- $output : mixed
- $diff : array<string|int, mixed>
writeHunk()
private
writeHunk(array<string|int, mixed> $diff, int $diffStartIndex, int $diffEndIndex, int $fromStart, int $fromRange, int $toStart, int $toRange, mixed $output) : void
Parameters
- $diff : array<string|int, mixed>
- $diffStartIndex : int
- $diffEndIndex : int
- $fromStart : int
- $fromRange : int
- $toStart : int
- $toRange : int
- $output : mixed