Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/imponeer/object-errors
Library that adds a possibility to collect errors for objects
https://github.com/imponeer/object-errors
errors hacktoberfest object php-library
Last synced: about 2 months ago
JSON representation
Library that adds a possibility to collect errors for objects
- Host: GitHub
- URL: https://github.com/imponeer/object-errors
- Owner: imponeer
- License: mit
- Created: 2018-03-11T22:46:38.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T00:12:13.000Z (5 months ago)
- Last Synced: 2024-08-01T03:16:36.470Z (5 months ago)
- Topics: errors, hacktoberfest, object, php-library
- Language: PHP
- Homepage:
- Size: 104 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![License](https://img.shields.io/github/license/imponeer/object-errors.svg?maxAge=2592000)](LICENSE)
[![Packagist](https://img.shields.io/packagist/v/imponeer/object-errors.svg)](https://packagist.org/packages/imponeer/object-errors) [![PHP](https://img.shields.io/packagist/php-v/imponeer/object-errors.svg)](http://php.net)
[![Packagist](https://img.shields.io/packagist/dm/imponeer/object-errors.svg)](https://packagist.org/packages/imponeer/object-errors)# Object Errors
Library that can be used for collecting errors on objects.
## Installation
To install and use this package, we recommend to use [Composer](https://getcomposer.org):
```bash
composer require imponeer/object-errors
```Otherwise you need to include manualy files from `src/` directory.
## Example
```php
use Imponeer/ObjectErrors/ErrorsCollection;
class Object {
/**
* Errors variable
*
* @var null|ErrorsCollection
*/
public $errors = null;
/**
* Constructor (binds new instance of ErrorsCollection to $errors var)
*/
public function __constructor() {
$this->errors = new ErrorsCollection();
}
/**
* This method do something
*/
public function doSomething() {
// here we should do something
if ($failed) {
$this->errors->add("Some error");
}
}
/**
* Renders object content
*
* @return string
*/
public function render() {
if ($this->errors->isEmpty()) {
return 'Everything fine';
} else {
return $this->errors->getHTML();
}
}}
```
## How to contribute?
If you want to add some functionality or fix bugs, you can fork, change and create pull request. If you not sure how this works, try [interactive GitHub tutorial](https://skills.github.com).
If you found any bug or have some questions, use [issues tab](https://github.com/imponeer/object-errors/issues) and write there your questions.