An open API service indexing awesome lists of open source software.

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

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();
```