php-extended / php-ensurer-object
An implementation of the php-ensure-interface library
7.0.6
2024-07-31 13:53 UTC
Requires
- php: >=8.0
- php-extended/php-ensurer-interface: ^7
- php-extended/php-inspector-object: ^7
Requires (Dev)
- dev-master
- 7.0.6
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.0.7
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.0.1
- 5.0.0
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 3.3.35
- 3.3.34
- 3.3.33
- 3.3.32
- 3.3.31
- 3.3.30
- 3.3.29
- 3.3.28
- 3.3.27
- 3.3.26
- 3.3.25
- 3.3.24
- 3.3.23
- 3.3.22
- 3.3.21
- 3.3.20
- 3.3.19
- 3.3.18
- 3.3.17
- 3.3.16
- 3.3.15
- 3.3.14
- 3.3.13
- 3.3.12
- 3.3.11
- 3.3.10
- 3.3.9
- 3.3.8
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.1
- 3.1.0
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
This package is auto-updated.
Last update: 2024-10-01 00:14:06 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.phar
from their website. - Then run the following command to install this library as dependency :
php composer.phar php-extended/php-ensurer-object ^7
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).