php-extended / php-ensurer-object
An implementation of the php-ensure-interface library
Package info
gitlab.com/php-extended/php-ensurer-object
pkg:composer/php-extended/php-ensurer-object
9.0.8
2026-07-21 08:38 UTC
Requires
- php: >=8.2
- php-extended/php-ensurer-interface: ^9
- php-extended/php-inspector-object: ^9
Requires (Dev)
This package is auto-updated.
Last update: 2026-07-21 06:40:59 UTC
README
An implementation of the php-ensure-interface library.
Installation
The installation of this library is made via composer and the autoloading of all classes of this library is made through their autoloader.
- Download
composer.pharfrom their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-ensurer-object ^9
Basic Usage
You may use this class the following way :
use PhpExtended\Ensurer\NotNullLooseEnsurer;
$ensurer = new LooseEnsurer(); // alternatively new StrictEnsurer();
$ensurer->asBoolean(1); // return true
$ensurer->asString(null); // returns ""
$ensurer->asObjectOf(new \DateTime(), \DateTime::class); // returns the object
$ensurer->asObjectOf(new \DateTime(), Foo::class); // throws \InvalidArgumentException
License
MIT (See license file).