for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* It's free open-source software released under the MIT License.
*
* @author Anatoly Nekhay <[email protected]>
* @copyright Copyright (c) 2018, Anatoly Nekhay
* @license https://github.com/sunrise-php/http-router/blob/master/LICENSE
* @link https://github.com/sunrise-php/http-router
*/
declare(strict_types=1);
namespace Sunrise\Http\Router\OpenApi\PhpTypeSchemaResolver;
use Reflector;
use Sunrise\Http\Router\OpenApi\Exception\UnsupportedPhpTypeException;
use Sunrise\Http\Router\OpenApi\OpenApiPhpTypeSchemaResolverInterface;
use Sunrise\Http\Router\OpenApi\Type;
use Symfony\Component\Uid\AbstractUid;
use Symfony\Component\Uid\Uuid;
use function is_a;
use function is_subclass_of;
* @since 3.0.0
final class SymfonyUidPhpTypeSchemaResolver implements OpenApiPhpTypeSchemaResolverInterface
{
public function supportsPhpType(Type $phpType, Reflector $phpTypeHolder): bool
return is_subclass_of($phpType->name, AbstractUid::class);
}
* @inheritDoc
public function resolvePhpTypeSchema(Type $phpType, Reflector $phpTypeHolder): array
$this->supportsPhpType($phpType, $phpTypeHolder) or throw new UnsupportedPhpTypeException();
$phpTypeSchema = [
'type' => Type::OAS_TYPE_NAME_STRING,
];
if (is_a($phpType->name, Uuid::class, true)) {
$phpTypeSchema['format'] = 'uuid';
return $phpTypeSchema;
public function getWeight(): int
return 0;