class Diff (View source)

Class Diff

Methods

__construct(array $a, array $b, array $options = [])

The constructor.

mixed
render(AbstractRenderer $renderer)

Render a diff using the supplied rendering class and return it.

array
getA(int $start = 0, int $end = null)

Get a range of lines from $start to $end from the first comparison string and return them as an array. If no values are supplied, the entire string is returned. It's also possible to specify just one line to return only that line.

array
getB(int $start = 0, int $end = null)

Get a range of lines from $start to $end from the second comparison string and return them as an array. If no values are supplied, the entire string is returned. It's also possible to specify just one line to return only that line.

array
getGroupedOpcodes()

Generate a list of the compiled and grouped opcodes for the differences between the two strings. Generally called by the renderer, this class instantiates the sequence matcher and performs the actual diff generation and return an array of the opcodes for it. Once generated, the results are cached in the diff class instance.

Details

__construct(array $a, array $b, array $options = [])

The constructor.

Parameters

array $a

Array containing the lines of the first string to compare.

array $b

Array containing the lines for the second string to compare.

array $options

Options (see $defaultOptions in this class)

mixed render(AbstractRenderer $renderer)

Render a diff using the supplied rendering class and return it.

Parameters

AbstractRenderer $renderer

An instance of the rendering object to use for generating the diff.

Return Value

mixed

The generated diff. Exact return value depends on the renderer used.

array getA(int $start = 0, int $end = null)

Get a range of lines from $start to $end from the first comparison string and return them as an array. If no values are supplied, the entire string is returned. It's also possible to specify just one line to return only that line.

Parameters

int $start

The starting number.

int $end

The ending number. If not supplied, only the item in $start will be returned.

Return Value

array

Array of all of the lines between the specified range.

array getB(int $start = 0, int $end = null)

Get a range of lines from $start to $end from the second comparison string and return them as an array. If no values are supplied, the entire string is returned. It's also possible to specify just one line to return only that line.

Parameters

int $start

The starting number.

int $end

The ending number. If not supplied, only the item in $start will be returned.

Return Value

array

Array of all of the lines between the specified range.

array getGroupedOpcodes()

Generate a list of the compiled and grouped opcodes for the differences between the two strings. Generally called by the renderer, this class instantiates the sequence matcher and performs the actual diff generation and return an array of the opcodes for it. Once generated, the results are cached in the diff class instance.

Return Value

array

Array of the grouped opcodes for the generated diff.