You are here

protected function ParameterBag::checkKeyIsValid in JSON-RPC 2.x

Same name and namespace in other branches
  1. 8 src/Object/ParameterBag.php \Drupal\jsonrpc\Object\ParameterBag::checkKeyIsValid()

Checks if the key is valid.

Throws

\InvalidArgumentException If the key is not valid.

2 calls to ParameterBag::checkKeyIsValid()
ParameterBag::ensure in src/Object/ParameterBag.php
Throw an exception if the bag does not have the parameter.
ParameterBag::has in src/Object/ParameterBag.php
Checks if the bag has a parameter.

File

src/Object/ParameterBag.php, line 92

Class

ParameterBag
Value class to hold multiple parameters.

Namespace

Drupal\jsonrpc\Object

Code

protected function checkKeyIsValid($key) {
  if ($this->positional && !is_int($key) && $key >= 0) {
    throw new \InvalidArgumentException('The parameters are by-position. Integer key required.');
  }
  elseif (!is_string($key)) {
    throw new \InvalidArgumentException('The parameters are by-name. String key required.');
  }
}