vendor/api-platform/core/src/Documentation/Documentation.php line 31

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of the API Platform project.
  4. *
  5. * (c) Kévin Dunglas <dunglas@gmail.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. declare(strict_types=1);
  11. namespace ApiPlatform\Documentation;
  12. use ApiPlatform\Metadata\Resource\ResourceNameCollection;
  13. /**
  14. * Generates the API documentation.
  15. *
  16. * @author Amrouche Hamza <hamza.simperfit@gmail.com>
  17. */
  18. final class Documentation implements DocumentationInterface
  19. {
  20. private $resourceNameCollection;
  21. private $title;
  22. private $description;
  23. private $version;
  24. private $mimeTypes = [];
  25. public function __construct(ResourceNameCollection $resourceNameCollection, string $title = '', string $description = '', string $version = '', array $formats = null)
  26. {
  27. $this->resourceNameCollection = $resourceNameCollection;
  28. $this->title = $title;
  29. $this->description = $description;
  30. $this->version = $version;
  31. if (null === $formats) {
  32. return;
  33. }
  34. @trigger_error(sprintf('Passing a 5th parameter to the constructor of "%s" is deprecated since API Platform 2.5', __CLASS__), \E_USER_DEPRECATED);
  35. foreach ($formats as $mimeTypes) {
  36. foreach ($mimeTypes as $mimeType) {
  37. $this->mimeTypes[] = $mimeType;
  38. }
  39. }
  40. }
  41. public function getMimeTypes(): array
  42. {
  43. @trigger_error(sprintf('The method "%s" is deprecated since API Platform 2.5, use the "formats" attribute instead', __METHOD__), \E_USER_DEPRECATED);
  44. return $this->mimeTypes;
  45. }
  46. public function getVersion(): string
  47. {
  48. return $this->version;
  49. }
  50. public function getDescription(): string
  51. {
  52. return $this->description;
  53. }
  54. public function getTitle(): string
  55. {
  56. return $this->title;
  57. }
  58. public function getResourceNameCollection(): ResourceNameCollection
  59. {
  60. return $this->resourceNameCollection;
  61. }
  62. }
  63. class_alias(Documentation::class, \ApiPlatform\Core\Documentation\Documentation::class);