Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sweetchuck/robo-serialize
https://github.com/sweetchuck/robo-serialize
robo robo-tasks serializer
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/sweetchuck/robo-serialize
- Owner: Sweetchuck
- Created: 2017-02-12T13:25:21.000Z (almost 8 years ago)
- Default Branch: 3.x
- Last Pushed: 2023-12-29T11:18:48.000Z (11 months ago)
- Last Synced: 2024-10-05T08:06:49.665Z (about 1 month ago)
- Topics: robo, robo-tasks, serializer
- Language: PHP
- Size: 192 KB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Robo task to serialize data structures
[![CircleCI](https://circleci.com/gh/Sweetchuck/robo-serialize/tree/3.x.svg?style=svg)](https://circleci.com/gh/Sweetchuck/robo-serialize/?branch=3.x)
[![codecov](https://codecov.io/gh/Sweetchuck/robo-serialize/branch/3.x/graph/badge.svg?token=M7avP9BiV1)](https://app.codecov.io/gh/Sweetchuck/robo-serialize/branch/3.x)## Install
Run `composer require sweetchuck/robo-serialize`
## Usage example
```php
getSerializer('json');
$writer = new StreamOutput(fopen($dstFileName, 'w+'));return $this
->collectionBuilder()
->addCode(function (RoboStateData $data): int {
$data['my_config.json'] = [
'description' => 'this is the initial value of the my_config.json',
];return 0;
})
->addCode($this->getTaskIndependentConfigManipulator1('my_config.json'))
->addCode($this->getTaskIndependentConfigManipulator2('my_config.json'))
->addTask($this
->taskSerialize()
->setSerializer($serializer)
->setWriter($writer)
->deferTaskConfiguration('setValue', 'my_config.json')
);
}protected function getTaskIndependentConfigManipulator1(string $stateKey): \Closure
{
return function (RoboStateData $data) use ($stateKey): int {
$data[$stateKey]['manipulator_1'] = 'foo';return 0;
};
}protected function getTaskIndependentConfigManipulator2(string $stateKey): \Closure
{
return function (RoboStateData $data) use ($stateKey): int {
$data[$stateKey]['manipulator_2'] = 'bar';return 0;
};
}
}
```