jorisros/data-compare

Component that is able to compare big data sets

v1.0.4 2019-10-16 23:53 UTC

This package is auto-updated.

Last update: 2024-04-15 19:20:59 UTC


README

Build Status Maintainability

DataCompare component

This is a component that enables you detect if there are changes between two arrays.

Requiments

This component is compatible from php 7.0 < 7.3.

Example

$product = Product::getBySku($xmlProduct['sku']);

if (!$product) {
    $product = new Product();
}

$dataproviderA = new \DataCompare\SimpleProvider();
$dataproviderA->addString('sku', $product->getSku());
$dataproviderA->addString('title', $product->getTitle());
$dataproviderA->addString('price', $product->getPrice());

$dataproviderB = new \DataCompare\SimpleProvider(); 
$dataproviderB->addString('sku', $jsonImport->sku);
$dataproviderB->addString('title', $jsonImport->title);
$dataproviderB->addString('price', $jsonImport->price);

$compareComponent = new \DataCompare\DataCompare($dataproviderA, $dataproviderB);

if (!$compareComponent->isTheSame()){
    // If result is not equal update the product
    $product->save()
}

TODO

  • Check if stucture of the array the same are
  • Gives back on which data set there is a problem