1
0

SearchQuery.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * @copyright 2020 Christoph Wurst <christoph@winzerhof-wurst.at>
  5. *
  6. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  7. * @author Joas Schilling <coding@schilljs.com>
  8. * @author John Molakvoæ <skjnldsv@protonmail.com>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OC\Search;
  27. use OCP\Search\ISearchQuery;
  28. class SearchQuery implements ISearchQuery {
  29. public const LIMIT_DEFAULT = 5;
  30. /** @var string */
  31. private $term;
  32. /** @var int */
  33. private $sortOrder;
  34. /** @var int */
  35. private $limit;
  36. /** @var int|string|null */
  37. private $cursor;
  38. /** @var string */
  39. private $route;
  40. /** @var array */
  41. private $routeParameters;
  42. /**
  43. * @param string $term
  44. * @param int $sortOrder
  45. * @param int $limit
  46. * @param int|string|null $cursor
  47. * @param string $route
  48. * @param array $routeParameters
  49. */
  50. public function __construct(string $term,
  51. int $sortOrder = ISearchQuery::SORT_DATE_DESC,
  52. int $limit = self::LIMIT_DEFAULT,
  53. $cursor = null,
  54. string $route = '',
  55. array $routeParameters = []) {
  56. $this->term = $term;
  57. $this->sortOrder = $sortOrder;
  58. $this->limit = $limit;
  59. $this->cursor = $cursor;
  60. $this->route = $route;
  61. $this->routeParameters = $routeParameters;
  62. }
  63. /**
  64. * @inheritDoc
  65. */
  66. public function getTerm(): string {
  67. return $this->term;
  68. }
  69. /**
  70. * @inheritDoc
  71. */
  72. public function getSortOrder(): int {
  73. return $this->sortOrder;
  74. }
  75. /**
  76. * @inheritDoc
  77. */
  78. public function getLimit(): int {
  79. return $this->limit;
  80. }
  81. /**
  82. * @inheritDoc
  83. */
  84. public function getCursor() {
  85. return $this->cursor;
  86. }
  87. /**
  88. * @inheritDoc
  89. */
  90. public function getRoute(): string {
  91. return $this->route;
  92. }
  93. /**
  94. * @inheritDoc
  95. */
  96. public function getRouteParameters(): array {
  97. return $this->routeParameters;
  98. }
  99. }