2017-02-02 12:19:16 -05:00
|
|
|
<?php
|
2023-11-07 08:43:01 -05:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2017-02-02 12:19:16 -05:00
|
|
|
/**
|
|
|
|
|
* @copyright Copyright (c) 2017 Robin Appelman <robin@icewind.nl>
|
|
|
|
|
*
|
2023-11-06 20:21:29 -05:00
|
|
|
* @author Maxence Lange <maxence@artificial-owl.com>
|
2017-11-06 09:56:42 -05:00
|
|
|
* @author Robin Appelman <robin@icewind.nl>
|
|
|
|
|
*
|
2017-02-02 12:19:16 -05:00
|
|
|
* @license GNU AGPL version 3 or any later version
|
|
|
|
|
*
|
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2021-06-04 15:52:51 -04:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2017-02-02 12:19:16 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2019-12-03 13:57:53 -05:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2017-02-02 12:19:16 -05:00
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
namespace OC\Files\Search;
|
|
|
|
|
|
|
|
|
|
use OCP\Files\Search\ISearchComparison;
|
|
|
|
|
|
|
|
|
|
class SearchComparison implements ISearchComparison {
|
2023-11-06 20:21:29 -05:00
|
|
|
private array $hints = [];
|
2017-02-02 12:19:16 -05:00
|
|
|
|
2023-11-06 20:21:29 -05:00
|
|
|
public function __construct(
|
|
|
|
|
private string $type,
|
|
|
|
|
private string $field,
|
2023-11-21 21:20:34 -05:00
|
|
|
private \DateTime|int|string|bool $value,
|
2023-11-06 20:21:29 -05:00
|
|
|
private string $extra = ''
|
|
|
|
|
) {
|
2017-02-02 12:19:16 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2023-11-07 08:43:01 -05:00
|
|
|
public function getType(): string {
|
2017-02-02 12:19:16 -05:00
|
|
|
return $this->type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2023-11-07 08:43:01 -05:00
|
|
|
public function getField(): string {
|
2017-02-02 12:19:16 -05:00
|
|
|
return $this->field;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2023-11-21 21:20:34 -05:00
|
|
|
* @return \DateTime|int|string|bool
|
2017-02-02 12:19:16 -05:00
|
|
|
*/
|
2023-11-21 21:20:34 -05:00
|
|
|
public function getValue(): string|int|bool|\DateTime {
|
2017-02-02 12:19:16 -05:00
|
|
|
return $this->value;
|
|
|
|
|
}
|
2021-08-23 09:01:03 -04:00
|
|
|
|
2023-11-07 08:43:01 -05:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
* @since 28.0.0
|
|
|
|
|
*/
|
2023-11-06 20:21:29 -05:00
|
|
|
public function getExtra(): string {
|
|
|
|
|
return $this->extra;
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-23 09:01:03 -04:00
|
|
|
public function getQueryHint(string $name, $default) {
|
|
|
|
|
return $this->hints[$name] ?? $default;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function setQueryHint(string $name, $value): void {
|
|
|
|
|
$this->hints[$name] = $value;
|
|
|
|
|
}
|
2022-11-02 07:44:51 -04:00
|
|
|
|
|
|
|
|
public static function escapeLikeParameter(string $param): string {
|
|
|
|
|
return addcslashes($param, '\\_%');
|
|
|
|
|
}
|
2017-02-02 12:19:16 -05:00
|
|
|
}
|