1. Go to this page and download the library: Download grzesie2k/hydrator 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/ */
grzesie2k / hydrator example snippets
$hydrator = $hydratorFactory->createHydrator('int[]'); // any valid type
$intList = $hydrator->hydrator([1, 2, 3]); // ✓ OK
$intList = $hydrator->hydrator([1, 'a', 2]); // ☹ exception
class Example
{
/**
* @param int $id
* @param string $name we can read types from PHPDoc
*/
public function __construct(int $id, $name) // or from type hints
{
// ... some operation
}
}
$hydrator = $hydratorFactory->createHydrator(Example::class);
$hydrator->hydrate(\json_decode('{"id":2,"name":"Adam"}')); // ✓ OK
$hydrator->hydrate(\json_decode('{"id":"Nope","name":"Janek"}')); // ☹ exception
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.