ilexn/config-object

This package is abandoned and no longer maintained. No replacement package was suggested.

Config Object

Fund package maintenance!
iLexN

0.2.1 2021-12-03 09:06 UTC

README

Generator for create data value object.

Latest Stable Version Total Downloads

GitHub Action Coverage Status Infection MSI

Installation

composer require ilexn/config-object

Usage example

<?php

declare(strict_types=1);

use Example\ConfigObject\GenNameCreate;
use Ilex\ConfigObject\CreateMode;
use Ilex\ConfigObject\GeneratorManager;
use Ilex\ConfigObject\Setting;
use Ilex\ConfigObject\Tests\Fake\One;

include 'vendor/autoload.php';

$setting = new class extends Setting {

    public function getTargetPath(): string
    {
        return __DIR__ . '/example';
    }

    public function getTargetNamespace(): string
    {
        return 'Example\ConfigObject';
    }

    public function getTargetClassName(): string
    {
        return 'GenNameCreate';
    }

    public function getData(): One
    {
        return new One();
    }

    public function allowClass(): array
    {
        return [One::class];
    }
};


$mode = CreateMode::each();
$generator = new \Ilex\ConfigObject\Generator();

$manager = new GeneratorManager($mode, $generator);
$manager->generate($setting);

$g = new GenNameCreate();
var_dump($g->getData()->getTargetPath());

Benchmark

benchmark subject set revs its mem_peak mode rstdev
JsonBenchmark benchBase 0 1000 5 2.417mb 25.600μs ±1.27%
JsonBenchmark benchEach 0 1000 5 5.216mb 287.363μs ±0.73%
JsonBenchmark benchOnce 0 1000 5 2.417mb 5.764μs ±2.15%
JsonBenchmark benchNone 0 1000 5 2.417mb 1.923μs ±3.01%

Todo

[ ] add general method.