81% of 146OPs |
100% of 26Lines |
74% of 23Branches |
5% of 19Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\tools\diff\decorator::decorate() | 146 | 81% | 26 | 100% | 23 | 74% | 19 | 5% |
| # | |
|---|---|
| 1 |
<?php |
| 2 | |
| 3 |
namespace mageekguy\atoum\tools\diff; |
| 4 | |
| 5 |
use |
| 6 |
mageekguy\atoum\tools |
| 7 |
; |
| 8 | |
| 9 |
class decorator |
| 10 |
{
|
| 11 |
public function decorate(tools\diff $diff)100% |
| 12 |
{
|
| 13 |
$string = ''; |
| 14 | |
| 15 |
$diff = array_filter($diff->make(), function($value) { return is_array($value) === true; });
|
| 16 | |
| 17 |
if (sizeof($diff) > 0) |
| 18 |
{
|
| 19 |
$string .= '-Expected' . PHP_EOL; |
| 20 |
$string .= '+Actual' . PHP_EOL; |
| 21 | |
| 22 |
foreach ($diff as $lineNumber => $diff) |
| 23 |
{
|
| 24 |
$lineNumber++; |
| 25 | |
| 26 |
$sizeofMinus = sizeof($diff['-']); |
| 27 |
$sizeofPlus = sizeof($diff['+']); |
| 28 | |
| 29 |
$string .= '@@ -' . $lineNumber . ($sizeofMinus <= 1 ? '' : ',' . $sizeofMinus) . ' +' . $lineNumber . ($sizeofPlus <= 1 ? '' : ',' . $sizeofPlus) . ' @@' . PHP_EOL; |
| 30 | |
| 31 |
array_walk($diff['-'], function(& $value) { $value = ($value == '' ? '' : '-' . $value); });
|
| 32 |
$minus = join(PHP_EOL, $diff['-']); |
| 33 | |
| 34 |
if ($minus != '') |
| 35 |
{
|
| 36 |
$string .= $minus . PHP_EOL; |
| 37 |
} |
| 38 | |
| 39 |
array_walk($diff['+'], function(& $value) { $value = ($value == '' ? '' : '+' . $value); });
|
| 40 |
$plus = join(PHP_EOL, $diff['+']); |
| 41 | |
| 42 |
if ($plus != '') |
| 43 |
{
|
| 44 |
$string .= $plus . PHP_EOL; |
| 45 |
} |
| 46 |
} |
| 47 |
} |
| 48 | |
| 49 |
return trim($string); |
| 50 |
} |
| 51 |
} |