/** * Validate new entry. Return true on success, throw Exception on failure. * * @param mixed $key * @param mixed $value * @return bool * @throws InvalidTypeException */ protected function validateEntry($key, $value) : bool { if (!$this->valueValidator->isValid($value)) { // Value invalid. throw InvalidTypeException::forValue($value, $this->valueValidator->getName()); } if ($key !== null && !$this->keyValidator->isValid($key)) { // Key invalid. throw InvalidTypeException::forValue($key, $this->keyValidator->getName()); } return true; }
/** * Validate new entry. Return true on success, throw Exception on failure. * * @param mixed $key * @param mixed $value * @return bool * @throws InvalidTypeException */ protected function validateEntry($key, $value) : bool { if ($key === null) { throw new InvalidTypeException('Cannot increment keys of type ' . $this->keyValidator->getName() . '. Please specify manually or use ArrayList.'); } if (!$this->valueValidator->isValid($value)) { // Value invalid. throw InvalidTypeException::forValue($value, $this->valueValidator->getName()); } if (!$this->keyValidator->isValid($key)) { // Key invalid. throw InvalidTypeException::forValue($key, $this->keyValidator->getName()); } return true; }