public static function unexpectedModel(string $expected, string $received) : InvalidArgumentException { return new self(sprintf("Expected model \"%s\" but received \"%s\".", $expected, $received)); }
/** * @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; }