Skip to content
/ guard Public

assertion library with reusable guard function

License

Notifications You must be signed in to change notification settings

texdc/guard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

guard

An extension for beberlei/assert that adds some extra assertions and a factory function to simplify usage.

installation

composer require texdc/guard

usage

namespace my\lib;

use function texdc\guard\verify;

function storeRating(int $rating) : void {
    verify($rating)->numericRange(1, 10, 'rating should be from 1 - 10');
    // ...
}

function speak(string $message, ?int $times = null) : void {
    verify($message)->notEmpty('message is required')->length(256, 'message is too long');
    verify($times, 'invalid multiplier')->nullOr()->isModulus(8);
    // ...
}

About

assertion library with reusable guard function

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages