1. Go to this page and download the library: Download revinate/php-getter-setter 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/ */
public function testExampleArrayVsObject() {
$json = '{"name":"example","type":"json","value":22}';
$object = json_decode($json);
$array = (array)$object;
// The object gets updated as well
$newObject = gs\set($object, 'type', 'Object');
// Only the new array contains the update.
$newArray = gs\set($array, 'type', 'Array');
$this->assertEquals($object, $newObject);
$this->assertNotEquals($array, $newArray);
}