public function read(AbstractStream $stream)
    {
        $key = parent::read($stream);
        $values = $this->getValues();

        if (array_key_exists($key, $values)) {
            $value = $values[$key];
        } else {
            $value = $this->getDefault();
        }

        if ($value === null) {
            throw new InvalidKeyException(
                "Value '{$key}' does not correspond to a valid enum key. Presented keys: '" .
                implode("', '", array_keys($values)) . "'"
            );
        }

        return $value;
    }