PHP code example of taluu / totem

1. Go to this page and download the library: Download taluu/totem library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

taluu / totem example snippets




use Totem\Snapshot\ArraySnapshot;

$array = ['foo' => 'bar', 'baz' => 'qux'];
$snapshot = new ArraySnapshot($array); // Totem\Snapshot\ArraySnapshot

$array['foo'] = 'fubar';
$set = $snapshot->diff(new ArraySnapshot($array)); // Totem\Set

var_dump($set->hasChanged('foo'),
         $set->getChange('foo')->getOld(),
         $set->getChange('foo')->getNew(),
         $set->hasChanged('bar'));

/* 
 * expected result :
 *
 * bool(true)
 * string(3) "bar"
 * string(5) "fubar"
 * bool(false)
 */