ApiPlatform\Core\Hydra\Serializer\DocumentationNormalizer::getRange PHP Method

getRange() private method

Gets the range of the property.
private getRange ( PropertyMetadata $propertyMetadata ) : string | null
$propertyMetadata ApiPlatform\Core\Metadata\Property\PropertyMetadata
return string | null
    private function getRange(PropertyMetadata $propertyMetadata)
    {
        $jsonldContext = $propertyMetadata->getAttributes()['jsonld_context'] ?? [];
        if (isset($jsonldContext['@type'])) {
            return $jsonldContext['@type'];
        }
        if (null === ($type = $propertyMetadata->getType())) {
            return;
        }
        if ($type->isCollection() && null !== ($collectionType = $type->getCollectionValueType())) {
            $type = $collectionType;
        }
        switch ($type->getBuiltinType()) {
            case Type::BUILTIN_TYPE_STRING:
                return 'xmls:string';
            case Type::BUILTIN_TYPE_INT:
                return 'xmls:integer';
            case Type::BUILTIN_TYPE_FLOAT:
                return 'xmls:number';
            case Type::BUILTIN_TYPE_BOOL:
                return 'xmls:boolean';
            case Type::BUILTIN_TYPE_OBJECT:
                if (null === ($className = $type->getClassName())) {
                    return;
                }
                if (is_a($className, \DateTimeInterface::class, true)) {
                    return 'xmls:dateTime';
                }
                if ($this->resourceClassResolver->isResourceClass($className)) {
                    return sprintf('#%s', $this->resourceMetadataFactory->create($className)->getShortName());
                }
                break;
        }
    }