2017 © Pedro Peláez
 

library multi-exception

MultiException

image

ntk-andr/multi-exception

MultiException

  • Friday, February 3, 2017
  • by ntk-andr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MultiException

Usage Example

use NtkAndr\MultiException;

function checkPassword($passwd): bool
{
    $errors = new MultiException();
    if (empty($passwd)) {
        $errors->add(new Exception('Empty password'));
    }
    if (strlen($passwd) < 6) {
        $errors->add(new Exception('The password is too short'));
    }
    if (!preg_match('~\d~', $passwd)) {
        $errors->add(new Exception('The password doesn\'t contain numbers'));
    }
    if (!$errors->isEmpty()) {
        throw $errors;
    }
    return true;
}

try {
    checkPassword('');
} catch (MultiException $errors) {
    foreach ($errors as $error) {
        echo $error->getMessage() . "\n";
    }
}

The Versions

03/02 2017

dev-master

9999999-dev https://github.com/ntk-andr/MultiException/

MultiException

  Sources   Download

MIT

The Requires

  • php ^7.0

 

by Andrey Usov

multiexception