Skip to content

Instantly share code, notes, and snippets.

@gonzaloserrano
Created March 13, 2015 16:33
Show Gist options
  • Save gonzaloserrano/dd16a79d42bcfc827f8b to your computer and use it in GitHub Desktop.
Save gonzaloserrano/dd16a79d42bcfc827f8b to your computer and use it in GitHub Desktop.
<?php
require_once 'vendor/autoload.php';
$localTable = [
["X", "Y"],
["X", "X"],
["X", "X"],
];
$remoteTable = [
["X", "Y"],
["X", "X"],
[null, "X"],
];
$originalLocalTable = $localTable; // because $localTable is passed by reference and modified
$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);
$htmlDiffRender = new \coopy_DiffRender();
$htmlDiffRender->usePrettyArrows(false);
$htmlDiffRender->render($tableDiff);
echo $htmlDiffRender->html();
$patch = new \coopy_HighlightPatch(
$localTableView,
$tableDiff
);
$patch->apply();
print_r($localTableView->getData());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment