Object file manipulator inspired by doctrine/ORM package
Warning. I write this for personal use. Documentation is really poor. If you are interested for use this package, contact me at alexandre.tomatis@gmail.com for get better documentation.
composer req atomatis/OFM
Create entity
Example with yaml file
<?php
declare(strict_types=1);
namespace App\Entity;
use Atomatis\OFM as OFM;
#[OFM\Entity(OFM\Entity::TYPE_YAML)]
final class Configuration
{
#[OFM\Parameter]
private ?string $foo;
#[OFM\Parameter]
private ?array $bar;
...
// getter/setter
...
Configuration
// init registry with Entity file path.
$registry = new Registry();
$registry->addFile(Configuration::class, (new RegistryConfiguration())->setPath('my/file/path/configuration.yaml'));
$entityManager = new EntityManager($registry);
Load file
# my/file/path/configuration.yaml
foo: 'hello here'
$configuration = $entityManager->load(Configuration::class);
$configuration->getFoo(); // return 'hello here'
$configuration->getBar(); // return null
Flush file
# my/file/path/configuration.yaml
foo: 'hello here'
$configuration = $entityManager->load(Configuration::class);
$configuration->setFoo('see you later');
$entityManager->flush($configuration);
# my/file/path/configuration.yaml
foo: 'see you later'