示例#1
0
文件: Field.php 项目: gdbots/pbj-php
 /**
  * @param mixed $default
  * @throws AssertionFailed
  * @throws \Exception
  */
 private function guardDefault($default)
 {
     if ($this->isASingleValue()) {
         $this->guardValue($default);
         return;
     }
     Assertion::nullOrIsArray($default, sprintf('Field [%s] default must be an array.', $this->name));
     if (null === $default) {
         return;
     }
     if ($this->isAMap()) {
         Assertion::true(ArrayUtils::isAssoc($default), sprintf('Field [%s] default must be an associative array.', $this->name));
     }
     foreach ($default as $k => $v) {
         Assertion::notNull($v, sprintf('Field [%s] default for key [%s] cannot be null.', $this->name, $k));
         $this->guardValue($v);
     }
 }