djthossi / ensure
Some PHP Traits for ensuring values
Installs: 2 777
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 2
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is auto-updated.
Last update: 2025-03-29 00:21:12 UTC
README
Some PHP Traits for ensuring values
How it works
The provided Ensure Traits will test if provided $valueToTest
has expected value.
- If
$valueToTest
is valid nothing happens - If
$valueToTest
is invalidInvalidValueException
is thrown
Available Ensure Traits
- EnsureIsBooleanTrait
- EnsureIsGreaterThanTrait
- EnsureIsIntegerTrait
- EnsureIsLowerThanTrait
- EnsureIsNotEmptyTrait
- EnsureIsStringTrait
- EnsureIsUrlTrait
How to install
You have several options to install this package
Composer
composer require djthossi/ensure
Git
git clone https://github.com/DjThossi/Ensure.git
Download
https://github.com/DjThossi/Ensure/archive/master.zip
Example
class Message { use EnsureIsStringTrait; const MESSAGE_IS_NOT_A_STRING = 1; /** * @param string $message */ public function __construct($message) { $this->ensureIsString('Message', $message, self::MESSAGE_IS_NOT_A_STRING); } }