Files
2026-09-30 14:01:18 +02:00

89 lines
2.0 KiB
PHP

<?php
/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
declare(strict_types=1);
namespace NCU\Search;
/**
* A property of the items an {@see IAccountScopedSearchProvider} returns.
*
* @experimental 36.0.0
*/
final class SearchPropertyDefinition {
/**
* @param non-empty-string $name The field name used in search comparisons
* @param string $title A human-readable label
* @param bool $searchable Whether the property can be used in a search query
* @param bool $selectable Whether the property is returned in each result's metadata
* @param bool $detailOnly Whether the property is too expensive to read for every search
* result, and is only returned by {@see IAccountScopedSearchProvider::get()}
* @param bool $indexed Whether searching the property is answered by an index rather than a scan
* @experimental 36.0.0
*/
public function __construct(
private readonly string $name,
private readonly string $title,
private readonly SearchPropertyType $type = SearchPropertyType::String,
private readonly bool $searchable = false,
private readonly bool $selectable = false,
private readonly bool $detailOnly = false,
private readonly bool $indexed = false,
) {
}
/**
* @return non-empty-string
* @experimental 36.0.0
*/
public function getName(): string {
return $this->name;
}
/**
* @experimental 36.0.0
*/
public function getTitle(): string {
return $this->title;
}
/**
* @experimental 36.0.0
*/
public function getType(): SearchPropertyType {
return $this->type;
}
/**
* @experimental 36.0.0
*/
public function isSearchable(): bool {
return $this->searchable;
}
/**
* @experimental 36.0.0
*/
public function isSelectable(): bool {
return $this->selectable;
}
/**
* @experimental 36.0.0
*/
public function isDetailOnly(): bool {
return $this->detailOnly;
}
/**
* @experimental 36.0.0
*/
public function isIndexed(): bool {
return $this->indexed;
}
}