Skip to content

Commit

Permalink
Refactors lib/private/FullTextSearch.
Browse files Browse the repository at this point in the history
Mainly using PHP8's constructor property promotion.

Signed-off-by: Faraz Samapoor <f.samapoor@gmail.com>
  • Loading branch information
fsamapoor committed Oct 10, 2023
1 parent e6d0105 commit 93c565c
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 499 deletions.
77 changes: 26 additions & 51 deletions lib/private/FullTextSearch/FullTextSearchManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,47 +39,35 @@
* @package OC\FullTextSearch
*/
class FullTextSearchManager implements IFullTextSearchManager {
/** @var IProviderService */
private $providerService;
private ?IProviderService $providerService;

/** @var IIndexService */
private $indexService;

/** @var ISearchService */
private $searchService;
private ?IIndexService $indexService;

private ?ISearchService $searchService;

/**
* @since 15.0.0
*
* @param IProviderService $providerService
*/
public function registerProviderService(IProviderService $providerService) {
public function registerProviderService(IProviderService $providerService): void {
$this->providerService = $providerService;
}

/**
* @since 15.0.0
*
* @param IIndexService $indexService
*/
public function registerIndexService(IIndexService $indexService) {
public function registerIndexService(IIndexService $indexService): void {
$this->indexService = $indexService;
}

/**
* @since 15.0.0
*
* @param ISearchService $searchService
*/
public function registerSearchService(ISearchService $searchService) {
public function registerSearchService(ISearchService $searchService): void {
$this->searchService = $searchService;
}

/**
* @since 16.0.0
*
* @return bool
*/
public function isAvailable(): bool {
if ($this->indexService === null ||
Expand All @@ -93,7 +81,6 @@ public function isAvailable(): bool {


/**
* @return IProviderService
* @throws FullTextSearchAppNotAvailableException
*/
private function getProviderService(): IProviderService {
Expand All @@ -106,7 +93,6 @@ private function getProviderService(): IProviderService {


/**
* @return IIndexService
* @throws FullTextSearchAppNotAvailableException
*/
private function getIndexService(): IIndexService {
Expand All @@ -119,7 +105,6 @@ private function getIndexService(): IIndexService {


/**
* @return ISearchService
* @throws FullTextSearchAppNotAvailableException
*/
private function getSearchService(): ISearchService {
Expand All @@ -134,15 +119,12 @@ private function getSearchService(): ISearchService {
/**
* @throws FullTextSearchAppNotAvailableException
*/
public function addJavascriptAPI() {
public function addJavascriptAPI(): void {
$this->getProviderService()->addJavascriptAPI();
}


/**
* @param string $providerId
*
* @return bool
* @throws FullTextSearchAppNotAvailableException
*/
public function isProviderIndexed(string $providerId): bool {
Expand All @@ -151,56 +133,52 @@ public function isProviderIndexed(string $providerId): bool {


/**
* @param string $providerId
* @param string $documentId
* @return IIndex
* @throws FullTextSearchAppNotAvailableException
*/
public function getIndex(string $providerId, string $documentId): IIndex {
return $this->getIndexService()->getIndex($providerId, $documentId);
}

/**
* @param string $providerId
* @param string $documentId
* @param string $userId
* @param int $status
*
* @see IIndex for available value for $status.
*
* @return IIndex
* @throws FullTextSearchAppNotAvailableException
*/
public function createIndex(string $providerId, string $documentId, string $userId, int $status = 0): IIndex {
public function createIndex(
string $providerId,
string $documentId,
string $userId,
int $status = 0,
): IIndex {
return $this->getIndexService()->createIndex($providerId, $documentId, $userId, $status);
}


/**
* @param string $providerId
* @param string $documentId
* @param int $status
* @param bool $reset
*
* @see IIndex for available value for $status.
*
* @throws FullTextSearchAppNotAvailableException
*/
public function updateIndexStatus(string $providerId, string $documentId, int $status, bool $reset = false) {
public function updateIndexStatus(
string $providerId,
string $documentId,
int $status,
bool $reset = false,
): void {
$this->getIndexService()->updateIndexStatus($providerId, $documentId, $status, $reset);
}

/**
* @param string $providerId
* @param array $documentIds
* @param int $status
* @param bool $reset
*
* @see IIndex for available value for $status.
*
* @throws FullTextSearchAppNotAvailableException
*/
public function updateIndexesStatus(string $providerId, array $documentIds, int $status, bool $reset = false) {
public function updateIndexesStatus(
string $providerId,
array $documentIds,
int $status,
bool $reset = false,
): void {
$this->getIndexService()->updateIndexesStatus($providerId, $documentIds, $status, $reset);
}

Expand All @@ -210,15 +188,12 @@ public function updateIndexesStatus(string $providerId, array $documentIds, int
*
* @throws FullTextSearchAppNotAvailableException
*/
public function updateIndexes(array $indexes) {
public function updateIndexes(array $indexes): void {
$this->getIndexService()->updateIndexes($indexes);
}


/**
* @param array $request
* @param string $userId
*
* @return ISearchResult[]
* @throws FullTextSearchAppNotAvailableException
*/
Expand Down
Loading

0 comments on commit 93c565c

Please sign in to comment.