dev-master
9999999-devSimple tester for validating value given by constant.
GPL-3.0 BSD-3-Clause GPL-2.0
The Development Requires
by Robert Jelen
validator const constant tester
Wallogit.com
2017 © Pedro Peláez
Simple tester for validating value given by constant.
Validating parameters defined by constants., (*1)
Because simple example is better than a thousand words., (*2)
User entity (without PHPDoc, constructor, getters, etc.):, (*3)
```php <?php, (*4)
use ConstValidator\Validator as Constant;, (*5)
class UserEntity {, (*6)
private $role;
public function setRole($role)
{
if(!Constant::validate("UserEntity::ROLE_*", $role)){
throw new Exception("Invalid role");
}
$this->role = $role;
}
const ROLE_MEMBER = 'member';
const ROLE_MODERATOR = 'moderator';
const ROLE_ADMIN = 'admin';
}, (*7)
Simple tester for validating value given by constant.
GPL-3.0 BSD-3-Clause GPL-2.0
validator const constant tester