Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created March 2, 2015 15:58
Show Gist options
  • Save gonzaloserrano/07948738bd3abc91545b to your computer and use it in GitHub Desktop.
Save gonzaloserrano/07948738bd3abc91545b to your computer and use it in GitHub Desktop.
daff-php broken example
<?php
require_once 'vendor/autoload.php';
$localTable = [
['col1', 'col2', 'col3', 'col4', 'col5', 'col6'],
[0, 0, 0, 0, 1, 0]
];
$remoteTable = [
['col1', 'col2', 'col3', 'col4', 'col5', 'col6'],
[0, 0, 0, 0, 2, 0]
];
$localTableView = new \coopy_PhpTableView($localTable);
$remoteTableView = new \coopy_PhpTableView($remoteTable);
$dataDiff = [];
$tableDiff = new \coopy_PhpTableView($dataDiff);
$highlighter = new \coopy_TableDiff(
\coopy_Coopy::compareTables($localTableView, $remoteTableView)->align(),
new \coopy_CompareFlags()
);
$highlighter->hilite($tableDiff);
$patch = new \coopy_HighlightPatch(
$localTableView,
$tableDiff
);
$patch->apply();
$patchedData = $localTableView->getData();
var_dump($patchedData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment