https://github.com/atiksoftware/php-class-schema-merger
PHP array migrate,replace or fix with schema and with default data
https://github.com/atiksoftware/php-class-schema-merger
Last synced: about 2 months ago
JSON representation
PHP array migrate,replace or fix with schema and with default data
- Host: GitHub
- URL: https://github.com/atiksoftware/php-class-schema-merger
- Owner: atiksoftware
- Created: 2018-09-05T01:06:32.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-09-05T01:11:58.000Z (almost 8 years ago)
- Last Synced: 2025-07-01T05:44:15.549Z (12 months ago)
- Language: PHP
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHP Array Merger with Schema
PHP array migrate,replace or fix with schema and with default data
----------
## Installation
### Using Composer
```sh
composer require atiksoftware/php-class-schema-merger
```
```php
require __DIR__.'/../vendor/autoload.php';
use \Atiksoftware\Schema\Merger;
$schemaMerger = new Merger();
```
#### _Example_
```php
$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);
```