12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- declare(strict_types=1);
- namespace OCP\Search;
- use JsonSerializable;
- use function array_values;
- final class SearchResult implements JsonSerializable {
-
- private $name;
-
- private $isPaginated;
-
- private $entries;
-
- private $cursor;
-
- private function __construct(string $name,
- bool $isPaginated,
- array $entries,
- $cursor = null) {
- $this->name = $name;
- $this->isPaginated = $isPaginated;
- $this->entries = $entries;
- $this->cursor = $cursor;
- }
-
- public static function complete(string $name, array $entries): self {
- return new self(
- $name,
- false,
- $entries
- );
- }
-
- public static function paginated(string $name,
- array $entries,
- $cursor): self {
- return new self(
- $name,
- true,
- $entries,
- $cursor
- );
- }
-
- public function jsonSerialize(): array {
- return [
- 'name' => $this->name,
- 'isPaginated' => $this->isPaginated,
- 'entries' => array_values($this->entries),
- 'cursor' => $this->cursor,
- ];
- }
- }
|