1<?php
2
3declare(strict_types=1);
4
5/**
6 * @copyright 2021 Anna Larch <anna.larch@gmx.net>
7 *
8 * @author Anna Larch <anna.larch@gmx.net>
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 */
26namespace OC\Calendar;
27
28use OCP\Calendar\ICalendarQuery;
29
30class CalendarQuery implements ICalendarQuery {
31
32	/** @var string */
33	private $principalUri;
34
35	/** @var array */
36	public $searchProperties;
37
38	/** @var string|null */
39	private $searchPattern;
40
41	/** @var array */
42	private $options;
43
44	/** @var int|null */
45	private $offset;
46
47	/** @var int|null */
48	private $limit;
49
50	/** @var string[] */
51	private $calendarUris = [];
52
53	public function __construct(string $principalUri) {
54		$this->principalUri = $principalUri;
55		$this->searchProperties = [];
56		$this->options = [
57			'types' => [],
58		];
59	}
60
61	public function getPrincipalUri(): string {
62		return $this->principalUri;
63	}
64
65	public function setPrincipalUri(string $principalUri): void {
66		$this->principalUri = $principalUri;
67	}
68
69	public function setSearchPattern(string $pattern): void {
70		$this->searchPattern = $pattern;
71	}
72
73	public function getSearchPattern(): ?string {
74		return $this->searchPattern;
75	}
76
77	public function addSearchProperty(string $value): void {
78		$this->searchProperties[] = $value;
79	}
80
81	public function getSearchProperties(): array {
82		return $this->searchProperties;
83	}
84
85	public function addSearchCalendar(string $calendarUri): void {
86		$this->calendarUris[] = $calendarUri;
87	}
88
89	/**
90	 * @return string[]
91	 */
92	public function getCalendarUris(): array {
93		return $this->calendarUris;
94	}
95
96	public function getLimit(): ?int {
97		return $this->limit;
98	}
99
100	public function setLimit(int $limit): void {
101		$this->limit = $limit;
102	}
103
104	public function getOffset(): ?int {
105		return $this->offset;
106	}
107
108	public function setOffset(int $offset): void {
109		$this->offset = $offset;
110	}
111
112	public function addType(string $value): void {
113		$this->options['types'][] = $value;
114	}
115
116	public function setTimerangeStart(\DateTimeImmutable $startTime): void {
117		$this->options['timerange']['start'] = $startTime;
118	}
119
120	public function setTimerangeEnd(\DateTimeImmutable $endTime): void {
121		$this->options['timerange']['end'] = $endTime;
122	}
123
124	public function getOptions(): array {
125		return $this->options;
126	}
127}
128