Validates and normalizes a key

@param  string $key
@throws InvalidArgumentException
@return void
555903
protected function normalizeKey(&$key)
    {
        $key = (string)$key;

        if ($key === '') {
            throw new InvalidArgumentException("An empty key isn't allowed");
        } elseif (($p = $this->getOptions()->getKeyPattern()) && !preg_match($p, $key)) {
            throw new InvalidArgumentException(
                "The key '{$key}' doesn't match against pattern '{$p}'"
            );
        }
    }
1030155
public function setKey($key)
    {
        $this->hash = null;

        if (empty($key)) {
            $this->key = null;
            return;
        }

        $this->key = (string) $key;
        $this->hash = $this->makeHash($key);
    }
267114
public function removeParam($key)
    {
        if (null !== $this->params) {
            unset($this->params[$key]);
            if (empty($this->params)) {
                $this->params = null;
            }
        }
    }
24818
public function remove(string $key): void
    {
        $key = $this->prepareKey($key);
        $this->properties = Arr::remove($this->properties, $key);
    }
890896
protected function ensureValidKeys($keys)
    {
        if (!is_array($keys) && !($keys instanceof \Traversable)) {
            throw new InvalidArgumentException('A cache key set must be either an array or a Traversable.');
        }

        foreach ($keys as $key) {
            $this->ensureValidKey($key);
        }
    }
402641
public function delete($key)
    {
        $keys = explode('.', $key);
        $key_string = '';
        foreach ($keys as $i => $_key) {
            $key_string = $key_string . ((is_numeric($_key) || $_key === '') ? "[{$_key}]" : "['{$_key}']");
        }
        $script = sprintf('unset($this->_params%s);', $key_string);
        eval($script);
    }
21039
private function validateKeyName($name)
    {
        if (! is_string($name)) {
            throw InvalidArgumentException::invalidType('key', 'string', $name);
        }

        $len = strlen($name);
        if ($len > 255 || $len < 1) {
            throw InvalidArgumentException::invalidLength('name', 1, 255);
        }
    }
725536
protected function normalizeOption($key)
    {
        try
        {
            return parent::normalizeOption($key);
        }
        catch(ClientException\UnknownOptionException $e)
        {
            switch($key)
            {
                case 'openssl_version':
                case 'opensslVersion':
                    return 'openssl_version';
                    break;
                default:
                    throw $e;
            }
        }
    }
776562
public function delete($key)
    {
        /* If $key is not valid string throws InvalidArgumentException */
        if (!$this->isString($key)) {
            throw new InvalidArgumentException('Cache key must be not empty string');
        }

        return $this->getCollection()->delete($key);
    }
1107828
private function validateKey($key)
    {
        if (!is_string($key) || $key === '') {
            throw new CacheException('Argument $key must be a valid non-empty string.');
        }
        if (strpbrk($key, '{}()/\@:') !== false) {
            throw new CacheException(sprintf('Key "%s" contains unsupported characters.', $key));
        }
    }
337408
public function normalize($key)
    {
        foreach ($this->chain as $normalizer) {
            $key = $normalizer->normalize($key);
        }

        return $key;
    }
984395
public function useKeyAsValue($key, $normalize = false)
    {
        if (true !== $normalize && !$this->isValidNodeName($key)) {
            throw new \InvalidArgumentException(sprintf('%s is an invalid node name', $key));
        }

        $this->nodeValueKey = $normalize ? $this->normalizer->normalize($key) : $key;
    }
1297320
public static function validateMultiple($keys)
    {
        foreach ($keys as $key) {
            if (!is_string($key) && !is_int($key)) {
                throw InvalidKeyException::forKey($key);
            }
        }
    }
597424
public function set($key, $value)
    {
        switch ($key) {
            case 'validator':
                $this->validators[] = $value;
                break;

            case 'normalizer':
                $this->normalizers[] = $value;
                break;

            default:
                if (!property_exists($this, $key)) {
                    throw new \InvalidArgumentException("Unrecognized config key: $key");
                }
                $this->$key = $value;
        }

        return $this;
    }
1176581
public function remove($key)
	{
		$this->validateKey($key);
		if ($this->has($key)) {
			unset($this->params[$key]);
			return true;
		} else {
			return false;
		}
	}
225299
protected function validateKey($key)
    {
        if (!is_string($key)) {
            throw new CacheKeyException("Cache key must be a string, " . gettype($key) . " given");
        }

        if (preg_match("/[^A-Za-z0-9\._-]/", $key)) {
            throw new CacheKeyException("Cache key contains invalid characters: {$key}");
        }

        if (strlen($key) > 64) {
            throw new CacheKeyException("Cache key cannot be longer than 64 characters: {$key}");
        }
    }
636374
public function has($key)
    {
        return (isset($this->headers[$this->normalizeKey($key)])) ? true : false;
    }