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;
    }