A PHP project for working with flexible data objects, supporting dynamic properties and array initialization.
- Dynamic Properties: Easily set and get properties on data objects.
- Array Initialization: Instantiate objects with an associative array of properties.
- Extensible: Create your own data object classes by extending the base
DataObject.
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; // 30This project uses PestPHP for testing.
To run the tests:
composer install
./vendor/bin/pestsrc/- Source code for data objectstests/- PestPHP test suite
- PHP 8.3+
- Composer
MIT