Some PHP Traits for ensuring values
The provided Ensure Traits will test if provided $valueToTest
has expected value.
- If
$valueToTest
is valid nothing happens - If
$valueToTest
is invalidInvalidValueException
is thrown
- EnsureIsBooleanTrait
- EnsureIsGreaterThanTrait
- EnsureIsIntegerTrait
- EnsureIsLowerThanTrait
- EnsureIsNotEmptyTrait
- EnsureIsStringTrait
- EnsureIsUrlTrait
You have several options to install this package
composer require djthossi/ensure
git clone https://github.com/DjThossi/Ensure.git
https://github.com/DjThossi/Ensure/archive/master.zip
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);
}
}