public function normalizeKey($key)
	{
		$normalizedKey = filter_var(
			(preg_match('(^-\\d+$)D', $key)) ? count($this->items) + $key : $key,
			FILTER_VALIDATE_INT,
			[
				'options' => [
					'min_range' => 0,
					'max_range' => count($this->items)
				]
			]
		);

		if ($normalizedKey === false)
		{
			throw new InvalidArgumentException("Invalid offset '" . $key . "'");
		}

		return $normalizedKey;
	}
public function normalizeKey($key)
	{
		$normalizedKey = filter_var(
			(preg_match('(^-\\d+$)D', $key)) ? count($this->items) + $key : $key,
			FILTER_VALIDATE_INT,
			[
				'options' => [
					'min_range' => 0,
					'max_range' => count($this->items)
				]
			]
		);

		if ($normalizedKey === false)
		{
			throw new InvalidArgumentException("Invalid offset '" . $key . "'");
		}

		return $normalizedKey;
	}
public function normalizeKey ( $ key ) { $ normalizedKey = filter_var ( ( preg_match ( '(^-\\d+$)D' , $ key ) ) ? count ( $ this -> items ) + $ key : $ key , FILTER_VALIDATE_INT , [ 'options' => [ 'min_range' => 0 , 'max_range' => count ( $ this -> items ) ] ] ) ; if ( $ normalizedKey === false ) { throw new InvalidArgumentException ( "Invalid offset '" . $ key . "'" ) ; } return $ normalizedKey ; }
Ensure that the key is a valid offset

Negative values count from the end of the list

@param  mixed   $key
@return integer
Ensure that the key is a valid offset