2017 © Pedro Peláez
 

library object-errors

Library that adds a possibility to collect errors for objects

image

imponeer/object-errors

Library that adds a possibility to collect errors for objects

  • Thursday, July 5, 2018
  • by MekDrop
  • Repository
  • 2 Watchers
  • 0 Stars
  • 34 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 36 % Grown

The README.md

License Packagist PHP Packagist, (*1)

Object Errors

A PHP library for collecting and managing errors associated with objects. Useful for tracking validation or processing errors in a structured way., (*2)

Installation

Install via Composer:, (*3)

composer require imponeer/object-errors

Alternatively, you can manually include the files from the src/ directory., (*4)

Usage

This library allows you to attach an error collection to your objects and manage errors easily., (*5)

Using as a property

Below is a simple usage example by directly creating an ErrorsCollection instance:, (*6)

use Imponeer\ObjectErrors\ErrorsCollection;

class MyObject {
    /**
     * @var ErrorsCollection|null
     */
    public $errors = null;

    public function __construct() {
        $this->errors = new ErrorsCollection();
    }

    public function doSomething() {
        // Example logic
        if ($failed) {
            $this->errors->add("Some error");
        }
    }

    public function render() {
        if ($this->errors->isEmpty()) {
            return 'Everything fine';
        } else {
            return $this->errors->getHtml();
        }
    }
}

Using as a trait

You can also use the provided ErrorsTrait to quickly add error handling to your classes:, (*7)

use Imponeer\ObjectErrors\ErrorsTrait;

class MyObject {
    use ErrorsTrait;

    public function doSomething() {
        if ($failed) {
            $this->setErrors("Some error");
        }
    }

    public function render() {
        if ($this->hasError()) {
            return $this->getHtmlErrors();
        }
        return 'Everything fine';
    }
}

Development

Below are useful commands for development. Each command should be run from the project root directory., (*8)

Run tests using PHPUnit:, (*9)

composer test

Check code style using PHP_CodeSniffer:, (*10)

composer phpcs

Automatically fix code style issues:, (*11)

composer phpcbf

Run static analysis using PHPStan:, (*12)

composer phpstan

API Documentation

For detailed API documentation, please visit the Object Errors Wiki., (*13)

How to contribute?

Contributions are welcome! If you want to add new features or fix bugs, please fork the repository, make your changes, and submit a pull request., (*14)

If you find any bugs or have questions, please use the issues tab to report them or ask questions., (*15)

The Versions

05/07 2018

dev-master

9999999-dev

Library that adds a possibility to collect errors for objects

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.6

 

The Development Requires

by Raimondas Rimkevičius

collection errors object

05/07 2018

dev-dependabot/composer/phpunit/phpunit-tw-5.2|tw-7.0

dev-dependabot/composer/phpunit/phpunit-tw-5.2|tw-7.0

Library that adds a possibility to collect errors for objects

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.6

 

The Development Requires

by Raimondas Rimkevičius

collection errors object

14/03 2018

1.0.0

1.0.0.0

Library that adds a possibility to collect errors for objects

  Sources   Download

MIT

The Requires

  • ext-json *
  • php >=5.6

 

The Development Requires

by Raimondas Rimkevičius

collection errors object