https://github.com/torunar/operation-result
This package provides a component that can be used to store results (data and errors) of some operation
https://github.com/torunar/operation-result
dto operation-result return
Last synced: 24 days ago
JSON representation
This package provides a component that can be used to store results (data and errors) of some operation
- Host: GitHub
- URL: https://github.com/torunar/operation-result
- Owner: torunar
- License: mit
- Created: 2021-10-30T10:53:38.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-11-10T12:40:37.000Z (over 4 years ago)
- Last Synced: 2024-11-28T04:10:00.274Z (about 1 year ago)
- Topics: dto, operation-result, return
- Language: PHP
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Operation result
# About
This package provides a component that can be used to store results (data and errors) of some operation: API query, system call, data parsing, etc.
This package aims to provide **simple tool** that can be used in cases where robust specific operation result classes create unnecessary complexity.
# Installation
```bash
$ composer require torunar/operation-result
```
# Usage
```php
setIsSuccessful(false);
$operationResult->addError($errorMessage, $errorCode);
} else {
$operationResult->setData($content, 'content');
}
// Check whether operation succeeded
$operationResult->isSuccessful();
// Get all data
$operationResult->getData();
// Get single data record
$operationResult->getData('content');
// Get error messages
$operationResult->getErrors();
```