Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- NAMESPACE ILLI\Core\Std\Def;
- USE ILLI\Core\Std\Exception\ArgumentExpectedException;
- USE ILLI\Core\Std\Def;
- CLASS ADV
- {
- private static $__gc = [];
- protected $__value = NULL;
- public function __construct($__splType)
- {
- $c = get_called_class();
- $s = &self::$__gc[$c];
- isset($s) ?: $s = Def::type($__splType);
- }
- public function validate($__value)
- {
- return $this->getADT()->validate($__value);
- }
- public function set($__value)
- {
- if(TRUE === $this->validate($__value))
- {
- $this->__data = $__value;
- return $this;
- }
- throw new ArgumentExpectedException([
- 'target' => get_called_class(),
- 'expected' => $this->getADT()->__toString(),
- 'detected' => $t = getType($v = $__value),
- 'value' => is_object($v)
- ? get_class($v)
- : ((is_string($v) && (class_exists($v) || interface_exists($v))) || is_scalar($v)) ? $v : $t
- ]);
- }
- public function get()
- {
- return $this->__data;
- }
- public function getADT()
- {
- return self::$__gc[get_called_class()];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement