PHP code example of chriha / data-objects
1. Go to this page and download the library: Download chriha/data-objects 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/ */
chriha / data-objects example snippets
use ClipMyHorseTV\DataObject;
use ClipMyHorseTV\DataObjects\Attributes\MapFrom;
class Person extends DataObject
{
#[MapFrom('name_attr')]
public string $name;
public int $age;
}
$person = Person::from(['name_attr' => 'Alice', 'age' => 30]);
echo $person->name; // Alice
echo $person->age; // 30