Wrapper for result of simplediff.
More...
List of all members.
Detailed Description
Wrapper for result of simplediff.
- Copyright:
- 2011-2012 Perforce Software. All rights reserved
- License:
- Please see LICENSE.txt in top-level folder of this distribution.
- Version:
- 2012.2/486814
Constructor & Destructor Documentation
Create a new diff result from simplediff output.
- Parameters:
-
array | $result | output from simplediff. |
P4Cms_Diff_Options | $options | original options given to compare. |
{
$this->_result = $result;
$this->_options = $options;
}
Member Function Documentation
P4Cms_Diff_Result::getChunks |
( |
| ) |
|
Get all value chunks.
Includes values that are the same between left and right as well those that differ.
- Returns:
- array list of value chunks (P4Cms_Diff_Chunk instances)
{
$chunks = array();
foreach ($this->getRawResult() as $rawChunk) {
$chunk = end($chunks);
if ($chunk && $chunk->isSame() && is_string($rawChunk)) {
$values = $chunk->getRawValues();
$values[] = $rawChunk;
$chunk->setRawValues($values);
} else {
$chunks[] = new P4Cms_Diff_Chunk((array) $rawChunk);
}
}
return $chunks;
}
P4Cms_Diff_Result::getDiffChunks |
( |
| ) |
|
Get only diff chunks (blocks of values where left and right differ).
- Returns:
- array list of differing value chunks
{
return array_filter(
$this->getChunks(),
function($chunk)
{
return !$chunk->isSame();
}
);
}
P4Cms_Diff_Result::getDiffCount |
( |
| ) |
|
Count all differences.
- Returns:
- int the count of all differences
{
return count(array_filter($this->getRawResult(), 'is_array'));
}
P4Cms_Diff_Result::getOption |
( |
$ |
name | ) |
|
Get a specific option from the original options.
- Parameters:
-
string | $name | the name of the option to get. |
- Returns:
- mixed the value of the option
P4Cms_Diff_Result::getOptions |
( |
| ) |
|
Get the original options that produced this result (ie.
the options passed to the compare method).
- Returns:
- P4Cms_Diff_Options the original options.
{
return $this->_options;
}
P4Cms_Diff_Result::getRawResult |
( |
| ) |
|
Access to raw simplediff result array.
{
if (!is_array($this->_result)) {
throw new P4Cms_Diff_Exception(
"Cannot get results. Results have not been set."
);
}
return $this->_result;
}
P4Cms_Diff_Result::hasDiffs |
( |
| ) |
|
Check if there are differences.
- Returns:
- bool true if there are diffs.
P4Cms_Diff_Result::isWhitespaceChange |
( |
$ |
semantic = true | ) |
|
Check if the only changes are whitespace changes.
- Parameters:
-
bool | $semantic | optional - defaults to true - consider semantic changes (e.g. splitting one word or joining two) a non-whitespace change. |
{
if (!$this->hasDiffs()) {
return false;
}
foreach ($this->getDiffChunks() as $chunk) {
if (!$chunk->isWhitespaceChange($semantic)) {
return false;
}
}
return true;
}
Member Data Documentation
P4Cms_Diff_Result::$_options = null [protected] |
P4Cms_Diff_Result::$_result = null [protected] |
The documentation for this class was generated from the following file: