CSVDiff
Table of Contents
LINE_KEY | "Line" | |
---|---|---|
STATYS_KEY | "Status" | |
DIFF_KEY | "Difference" | |
$from_file_path | ||
$to_file_path | ||
$diffArray | ||
__construct() | Constructor | mixed |
getDiffFromFiles() | Return an Array string describing the diff between a "From" and a "To" string | array |
getHtmlFromDiff() | Generates a labeled HTML table with all the changed highlighted by color | html |
getJsonFromDiff() | Return an JSONObject with the lines and changes | json |
getDiff() | Generates array with the difference between the object files $from_file_path & private $to_file_path | array |
lineExist() | Checks if the given line after the cursor in the file handler | cursoroffset |
markLine() | Marks line in the object internal $diffArray | mixed |
highlightDiff() | Function to highlight the diff between strings | string |
Constants
LINE_KEY
mixed
$LINE_KEY
= "Line"
STATYS_KEY
mixed
$STATYS_KEY
= "Status"
DIFF_KEY
mixed
$DIFF_KEY
= "Difference"
Properties
$from_file_path
private
mixed
$from_file_path
= ''
$to_file_path
private
mixed
$to_file_path
= ''
$diffArray
private
mixed
$diffArray
= array()
Methods
__construct()
Constructor
public
__construct(
$from_file_path :
mixed
, $to_file_path :
mixed
)
: mixed
Creates an instance of the CSVDiff Library based on the two input file paths
Parameters
- $from_file_path : mixed
- $to_file_path : mixed
Return values
mixedgetDiffFromFiles()
Return an Array string describing the diff between a "From" and a "To" string
public
static getDiffFromFiles(
$from_file_path :
mixed
, $to_file_path :
mixed
)
: array
Parameters
- $from_file_path : mixed
- $to_file_path : mixed
Return values
array —contains all lines from the new version and lines removed from the previous ones each value of the array contains: "Line" - new version of the line "Status" - DiffEnum with the change on the current line "Difference" (optional) - if the status is DiffEnum::UPDATED will contain the changes {OLD}{NEW}
getHtmlFromDiff()
Generates a labeled HTML table with all the changed highlighted by color
public
static getHtmlFromDiff(
$diff :
mixed
)
: html
Parameters
- $diff : mixed
Return values
html —table and labels
getJsonFromDiff()
Return an JSONObject with the lines and changes
public
static getJsonFromDiff(
$diff :
mixed
)
: json
Parameters
- $diff : mixed
Return values
json —array all lines from the new version and lines removed from the previous ones each value of the array contains: "Line" - new version of the line "Status" - DiffEnum with the change on the current line "Difference" (optional) - if the status is DiffEnum::UPDATED will contain the changes {OLD}{NEW}
getDiff()
Generates array with the difference between the object files $from_file_path & private $to_file_path
private
getDiff(
)
: array
Tags
Return values
array —contains all lines from the new version and lines removed from the previous ones each value of the array contains: "Line" - new version of the line "Status" - DiffEnum with the change on the current line "Difference" (optional) - if the status is DiffEnum::UPDATED will contain the changes {OLD}{NEW}
lineExist()
Checks if the given line after the cursor in the file handler
private
lineExist(
$str :
mixed
, $handler :
mixed
)
: cursoroffset
Parameters
- $str : mixed
- $handler : mixed
Return values
cursoroffset —if exists OR -1 if line was not found
markLine()
Marks line in the object internal $diffArray
private
markLine(
$str :
mixed
, $enum :
mixed
[, $difference :
mixed
= null ]
)
: mixed
Parameters
- $str : mixed
- $enum : mixed
- $difference : mixed = null
Return values
mixedhighlightDiff()
Function to highlight the diff between strings
private
highlightDiff(
$old :
mixed
, $new :
mixed
)
: string
Parameters
- $old : mixed
- $new : mixed
Return values
string —line with the changes bewtween } example: startLine{oldValue}{newValue}endOfLine