PHP code example of imponeer / toarray-interface
1. Go to this page and download the library: Download imponeer/toarray-interface 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/ */
imponeer / toarray-interface example snippets
use Imponeer/ToArrayInterface;
class DummyObject implements ToArrayInterface {
/**
* Converts object to array
*
* @return array
*/
public function toArray(): array {
return array(
'hash' => sha1(time())
);
}
}
$instance = new DummyObject();
if ($instance instanceof ToArrayInterface) {
var_dump($instance->toArray());
}