vendor/nelmio/api-doc-bundle/PropertyDescriber/DateTimePropertyDescriber.php line 21

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the NelmioApiDocBundle package.
  4. *
  5. * (c) Nelmio
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Nelmio\ApiDocBundle\PropertyDescriber;
  11. use OpenApi\Annotations as OA;
  12. use Symfony\Component\PropertyInfo\Type;
  13. class DateTimePropertyDescriber implements PropertyDescriberInterface
  14. {
  15. use NullablePropertyTrait;
  16. public function describe(array $types, OA\Schema $property, array $groups = null)
  17. {
  18. $property->type = 'string';
  19. $property->format = 'date-time';
  20. $this->setNullableProperty($types[0], $property);
  21. }
  22. public function supports(array $types): bool
  23. {
  24. return 1 === count($types)
  25. && Type::BUILTIN_TYPE_OBJECT === $types[0]->getBuiltinType()
  26. && is_a($types[0]->getClassName(), \DateTimeInterface::class, true);
  27. }
  28. }