public function getEncoderForType(string $type): IEncoder
    {
        $normalizedType = self::normalizeType($type);

        if (isset($this->encodersByType[$normalizedType])) {
            return $this->encodersByType[$normalizedType];
        }

        if (class_exists($type)) {
            if ($this->defaultObjectEncoder === null) {
                throw new OutOfBoundsException('No default object encoder is registered');
            }

            return $this->defaultObjectEncoder;
        }

        if ($this->defaultScalarEncoder === null) {
            throw new OutOfBoundsException('No default scalar encoder is registered');
        }

        return $this->defaultScalarEncoder;
    }
public function getEncoderForType(string $type): IEncoder
    {
        $normalizedType = self::normalizeType($type);

        if (isset($this->encodersByType[$normalizedType])) {
            return $this->encodersByType[$normalizedType];
        }

        if (class_exists($type)) {
            if ($this->defaultObjectEncoder === null) {
                throw new OutOfBoundsException('No default object encoder is registered');
            }

            return $this->defaultObjectEncoder;
        }

        if ($this->defaultScalarEncoder === null) {
            throw new OutOfBoundsException('No default scalar encoder is registered');
        }

        return $this->defaultScalarEncoder;
    }
public function getEncoderForType ( string $ type ) : IEncoder { $ normalizedType = self :: normalizeType ( $ type ) ; if ( isset ( $ this -> encodersByType [ $ normalizedType ] ) ) { return $ this -> encodersByType [ $ normalizedType ] ; } if ( class_exists ( $ type ) ) { if ( $ this -> defaultObjectEncoder === null ) { throw new OutOfBoundsException ( 'No default object encoder is registered' ) ; } return $ this -> defaultObjectEncoder ; } if ( $ this -> defaultScalarEncoder === null ) { throw new OutOfBoundsException ( 'No default scalar encoder is registered' ) ; } return $ this -> defaultScalarEncoder ; }
Gets the encoder for a type

@param string $type The type whose encoder we want
@return IEncoder The encoder for the input type
Gets the encoder for a type