Giter Club home page Giter Club logo

object-errors's Introduction

License Packagist PHP Packagist

Object Errors

Library that can be used for collecting errors on objects.

Installation

To install and use this package, we recommend to use Composer:

composer require imponeer/object-errors

Otherwise you need to include manualy files from src/ directory.

Example

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.

If you found any bug or have some questions, use issues tab and write there your questions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.