atiksoftware / php-class-schema-merger
PHP array migrate,replace or fix with schema and with default data
1.0
2018-09-05 01:09 UTC
Requires
This package is auto-updated.
Last update: 2024-11-05 19:04:49 UTC
README
PHP array migrate,replace or fix with schema and with default data
Installation
Using Composer
composer require atiksoftware/php-class-schema-merger
require __DIR__.'/../vendor/autoload.php'; use \Atiksoftware\Schema\Merger; $schemaMerger = new Merger();
Example
$schemaMerger->setSchema([ "_id" => [ "_type" => "string", "_default" => "5f5e100" ], "name" => [ "_type" => "string", "_default" => "Yeni başlık", "_format" => "fullname" ], "title" => [ "_type" => "array", "TR" => [ "_type" => "string", "_default" => "Türkçe Başlık", "_format" => "upfirst" ], "EN" => [ "_type" => "string", "_default" => "English Title" ], ], "tags" => [ "_type" => "array", "_default" => [ ], ], "date" => [ "_type" => "array", "edit" => [ "_type" => "integer", "_default" => time() ] ], "admin" => [ "_type" => "boolean", "_default" => false ], "age" => [ "_type" => "int", "_default" => 15, "_min" => 5, "_max" => 35, ], ]); $item = [ "name" => "Mansur atik", "title" => [ "TR" => "Nasıl" ], "admin" => 1, "age" => 434 ]; $result = $schemaMerger->Migrate($item); var_dump($result);