ISearchOrder.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCP\Files\Search;
  7. use OCP\Files\FileInfo;
  8. /**
  9. * @since 12.0.0
  10. */
  11. interface ISearchOrder {
  12. /**
  13. * @since 12.0.0
  14. */
  15. public const DIRECTION_ASCENDING = 'asc';
  16. /**
  17. * @since 12.0.0
  18. */
  19. public const DIRECTION_DESCENDING = 'desc';
  20. /**
  21. * The direction to sort in, either ISearchOrder::DIRECTION_ASCENDING or ISearchOrder::DIRECTION_DESCENDING
  22. *
  23. * @return string
  24. * @since 12.0.0
  25. */
  26. public function getDirection(): string;
  27. /**
  28. * The field to sort on
  29. *
  30. * @return string
  31. * @since 12.0.0
  32. */
  33. public function getField(): string;
  34. /**
  35. * extra means data are not related to the main files table
  36. *
  37. * @return string
  38. * @since 28.0.0
  39. */
  40. public function getExtra(): string;
  41. /**
  42. * Apply the sorting on 2 FileInfo objects
  43. *
  44. * @param FileInfo $a
  45. * @param FileInfo $b
  46. * @return int -1 if $a < $b, 0 if $a = $b, 1 if $a > $b (for ascending, reverse for descending)
  47. * @since 22.0.0
  48. */
  49. public function sortFileInfo(FileInfo $a, FileInfo $b): int;
  50. }