2017 © Pedro Peláez
 

library predict-exception

Simplified predictions if a piece of codes throws an Exception

image

try/predict-exception

Simplified predictions if a piece of codes throws an Exception

  • Thursday, February 8, 2018
  • by troublete
  • Repository
  • 1 Watchers
  • 0 Stars
  • 50 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

predict-exception

Simplified predictions if a piece of codes throws an Exception, (*1)

Build Status, (*2)

Install

$ composer require try/predict-exception

Usage

<?php
require_once '/path/to/autoload.php';

use TryPhp\PredictExeptionTrait;

$assertions = new class() {
    use PredictExeptionTrait();
} 

$assertions->predictException(function () {
    throw new \RuntimeException('Oooops. Something broke.')
}, \RuntimeException::class); // won't throw an exception

$assertions->predictException(function () {
}, \Exception::class); // will throw an exception

$assertions->predictException(function () {
    throw new \RuntimeException('something else happened.');
}, \Exception::class); // will throw an exception

API

Methods

predictException($capture, $exceptionClass)

Method to check if a given piece of code throws an Throwable of the expected type., (*3)

Arguments
Arguments Type Description
$capture callable Closure in which the Throwable shall be thrown.
$exceptionClass string Class of the Throwable that is expected to be thrown.

License

GPL-2.0 © Willi Eßer, (*4)

The Versions

08/02 2018

dev-master

9999999-dev

Simplified predictions if a piece of codes throws an Exception

  Sources   Download

GPL-2.0

by Willi Eßer

08/02 2018

1.1.0

1.1.0.0

Simplified predictions if a piece of codes throws an Exception

  Sources   Download

GPL-2.0

by Willi Eßer

25/10 2017

1.0.0

1.0.0.0

Simplified predictions if a piece of codes throws an Exception

  Sources   Download

GPL-2.0

by Willi Eßer