示例#1
0
文件: Field.php 项目: gdbots/pbj-php
 /**
  * @param mixed $value
  * @throws AssertionFailed
  * @throws \Exception
  */
 public function guardValue($value)
 {
     if ($this->required) {
         Assertion::notNull($value, sprintf('Field [%s] is required and cannot be null.', $this->name));
     }
     if (null !== $value) {
         $this->type->guard($value, $this);
     }
     if (null !== $this->assertion) {
         call_user_func($this->assertion, $value, $this);
     }
 }