private function getType(string $type, bool $isCollection, string $className = null, bool $readableLink = null) : array
{
if ($isCollection) {
return ['type' => 'array', 'items' => $this->getType($type, false, $className, $readableLink)];
}
if (Type::BUILTIN_TYPE_STRING === $type) {
return ['type' => 'string'];
}
if (Type::BUILTIN_TYPE_INT === $type) {
return ['type' => 'integer'];
}
if (Type::BUILTIN_TYPE_FLOAT === $type) {
return ['type' => 'number'];
}
if (Type::BUILTIN_TYPE_BOOL === $type) {
return ['type' => 'boolean'];
}
if (Type::BUILTIN_TYPE_OBJECT === $type) {
if (null === $className) {
return ['type' => 'string'];
}
if (is_subclass_of($className, \DateTimeInterface::class)) {
return ['type' => 'string', 'format' => 'date-time'];
}
if (!$this->resourceClassResolver->isResourceClass($className)) {
return ['type' => 'string'];
}
if (true === $readableLink) {
return ['$ref' => sprintf('#/definitions/%s', $this->resourceMetadataFactory->create($className)->getShortName())];
}
}
return ['type' => 'string'];
}