1
0

ShapeDescriptor.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCP\TaskProcessing;
  7. /**
  8. * Data object for input output shape entries
  9. * @since 30.0.0
  10. */
  11. class ShapeDescriptor implements \JsonSerializable {
  12. /**
  13. * @param string $name
  14. * @param string $description
  15. * @param EShapeType $shapeType
  16. * @since 30.0.0
  17. */
  18. public function __construct(
  19. private string $name,
  20. private string $description,
  21. private EShapeType $shapeType,
  22. ) {
  23. }
  24. /**
  25. * @return string
  26. * @since 30.0.0
  27. */
  28. public function getName(): string {
  29. return $this->name;
  30. }
  31. /**
  32. * @return string
  33. * @since 30.0.0
  34. */
  35. public function getDescription(): string {
  36. return $this->description;
  37. }
  38. /**
  39. * @return EShapeType
  40. * @since 30.0.0
  41. */
  42. public function getShapeType(): EShapeType {
  43. return $this->shapeType;
  44. }
  45. /**
  46. * @return array{name: string, description: string, type: "Number"|"Text"|"Audio"|"Image"|"Video"|"File"|"ListOfNumbers"|"ListOfTexts"|"ListOfImages"|"ListOfAudios"|"ListOfVideos"|"ListOfFiles"}
  47. * @since 30.0.0
  48. */
  49. public function jsonSerialize(): array {
  50. /** @var "Number"|"Text"|"Audio"|"Image"|"Video"|"File"|"ListOfNumbers"|"ListOfTexts"|"ListOfImages"|"ListOfAudios"|"ListOfVideos"|"ListOfFiles" $type */
  51. $type = $this->getShapeType()->name;
  52. return [
  53. 'name' => $this->getName(),
  54. 'description' => $this->getDescription(),
  55. 'type' => $type,
  56. ];
  57. }
  58. }