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;
    }
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;
    }
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 ; }
Read key from Stream, and return value by this key or default value.

@param AbstractStream $stream Stream from which resolved field reads.
@return object|integer|double|string|array|boolean|callable Value by read key or default value if present.
@throws InvalidKeyException If read key is not exist and default value is not presented.
Read key from Stream and return value by this key or default value .