protected function typeToJsonLd(Type\TypeInterface $type)
    {
        $typeName = (new \ReflectionClass($type))->getShortName();
        if (strlen($typeName) > 4 && substr($typeName, -4) === 'Type') {
            $typeName = substr($typeName, 0, -4);
        }

        $jsonLd = [
            '@type' => $typeName,
        ];

        if ($type->getId()) {
            $jsonLd['@id'] = $type->getId();
        }

        $publicMethods = (new \ReflectionClass($type))->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($publicMethods as $method) {
            $methodName = $method->getName();
            if (substr($methodName, 0, 3) !== 'get') {
                continue;
            }

            $key = lcfirst(substr($methodName, 3));
            if ($key == 'itemListElements') {
                $key = 'itemListElement';
            }

            $value = $type->$methodName();
            if (in_array($methodName, ['getId', 'getSchemaUrl']) || $value === null) {
                continue;
            } elseif (is_array($value)) {
                $jsonLd[$key] = [];
                foreach ($value as $item) {
                    $jsonLd[$key][] = $this->valueToJsonLd($item);
                }
            } else {
                $jsonLd[$key] = $this->valueToJsonLd($value);
            }
        }

        return $jsonLd;
    }