Dumplie\Metadata\Exception\InvalidArgumentException::unexpectedModel PHP Метод

unexpectedModel() публичный статический Метод

public static unexpectedModel ( string $expected, string $received ) : InvalidArgumentException
$expected string
$received string
Результат InvalidArgumentException
    public static function unexpectedModel(string $expected, string $received) : InvalidArgumentException
    {
        return new self(sprintf("Expected model \"%s\" but received \"%s\".", $expected, $received));
    }

Usage Example

Пример #1
0
 /**
  * @param TypeSchema $definition
  * @return bool
  * @throws InvalidArgumentException
  */
 public function isValid(TypeSchema $definition) : bool
 {
     if (mb_strtolower($definition->name()) !== mb_strtolower($this->typeSchemaName())) {
         throw InvalidArgumentException::unexpectedModel($definition->name(), $this->typeSchemaName());
     }
     foreach ($this->fields as $fieldName => $value) {
         $field = $definition->getFieldDefinition($fieldName);
         if (!$field->isValid($value)) {
             return false;
         }
     }
     return true;
 }