Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class test{}
- class a extends \ILLI\Base\Component\Structure\aStructure
- {
- private $__test = NULL;
- public function __construct()
- {
- $this->__test = new Test;
- $this->tStructure_define('functionName', [
- Prop::FLAG => Flag::REQUIRED | Flag::EXPECT_WHITELIST,
- Prop::INITIAL => NULL,
- Prop::TYPE => ['string'],
- Prop::WHITELIST => ['foo', 'bar', $this->__test], // Flag::EXPECT_WHITELIST set: foo is allowed!
- Prop::BLACKLIST => ['foo', 'bob'],
- Prop::ON_COMPARE => function($value)
- {
- },
- Prop::ON_SET => [
- function($value)
- {
- //throw new \Exception('boo');
- return $value;
- }
- ],
- ]);
- $this->tStructure_define('name', 'string');
- $this->tStructure_define('lastName');
- }
- public function validate($__field, $__value)
- {
- switch($__field):
- case 'name':
- return substr($__value, 0, 2) !== '__';
- break;
- case 'lastName':
- return $__value !== 'CH';
- break;
- endswitch;
- }
- }
- $a = new a;
- $a->functionName = 'bab'; // ValueComparisonWhitelistException
- //$a->functionName = new Test; // ValueExpectedException: strict compare
- var_dump($a);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement