robotdance/php-arguments

Utility class for method arguments validation.

v0.0.4 2016-06-01 16:45 UTC

This package is not auto-updated.

Last update: 2024-06-08 18:10:41 UTC


README

Code Climate Test Coverage Issue Count

Formerly monochromist/php-arguments

PHP-Arguments is an utility class for arguments validation code. Nothing special here, just some utility methods for libraries that need to enforce arguments validation and provide better error messages to developers using a library.

Example

use robotdance/Arguments;
...
public function doSomething($arg1, $arg2, $arg3, $arg4) {
  // string or boolean required
  Arguments::validate($arg1, ['string', 'boolean'];
  // integer required
  Arguments::validate($arg2, ['integer']);
  // not null required
  Arguments::notNull($arg3);
  // check if $arg4 is a string=>any associative array
  Arguments::validateAssociativeArray($arg4);
}

Setup

PHP-Arguments uses Composer as dependency manager.

$ composer install

You may also generate documentation:

$ ./bin/phpdoc -d ./src/ -t ./docs/

Testing

$ ./bin/phpunit

Contribute

Simply fork, code your tests and modifications, write a good commit message and submit a pull request. All tests must pass and the coverage must remains at 100%.

References

PHP the right way