1
0

LanguageTuple.php 964 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. namespace OCP\Translation;
  8. use JsonSerializable;
  9. /**
  10. * @since 26.0.0
  11. * @deprecated 30.0.0
  12. */
  13. class LanguageTuple implements JsonSerializable {
  14. /**
  15. * @since 26.0.0
  16. */
  17. public function __construct(
  18. private string $from,
  19. private string $fromLabel,
  20. private string $to,
  21. private string $toLabel
  22. ) {
  23. }
  24. /**
  25. * @since 26.0.0
  26. * @return array{from: string, fromLabel: string, to: string, toLabel: string}
  27. */
  28. public function jsonSerialize(): array {
  29. return [
  30. 'from' => $this->from,
  31. 'fromLabel' => $this->fromLabel,
  32. 'to' => $this->to,
  33. 'toLabel' => $this->toLabel,
  34. ];
  35. }
  36. /**
  37. * @since 26.0.0
  38. */
  39. public static function fromArray(array $data): LanguageTuple {
  40. return new self(
  41. $data['from'],
  42. $data['fromLabel'],
  43. $data['to'],
  44. $data['toLabel'],
  45. );
  46. }
  47. }