Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrself/php-sync
https://github.com/mrself/php-sync
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mrself/php-sync
- Owner: mrself
- License: mit
- Created: 2019-02-03T16:46:20.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2021-09-19T14:14:31.000Z (over 3 years ago)
- Last Synced: 2024-08-05T22:52:48.830Z (6 months ago)
- Language: PHP
- Size: 67.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
```php
// From array to array
$sync = Sync::make([
'source' => ['a' => 1],
'target' => [],
'mapping' => ['a']
]);
$sync->getTarget()['a'] === 1;// =======
// From array to object
$targetObject = (object) [];
$sync = Sync::make([
'source' => ['a' => 1],
'target' => $targetObject,
'mapping' => ['a']
]);
$targetObject->a === 1;// =======
// Extending from Sync
// Formatting values
$target = [];
$source = ['a' => 1];
$mapping = ['a'];
$sync = new class extends Sync {
public function formatA($value)
{
return $value + 1;
}
};
$sync->init(compact('target', 'source', 'mapping'));
$sync->sync();