diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Service/CliService.php | 31 | ||||
-rw-r--r-- | lib/Service/ConfigService.php | 62 | ||||
-rw-r--r-- | lib/Service/IndexService.php | 40 | ||||
-rw-r--r-- | lib/Service/MiscService.php | 77 | ||||
-rw-r--r-- | lib/Service/PlatformService.php | 19 | ||||
-rw-r--r-- | lib/Service/ProviderService.php | 45 | ||||
-rw-r--r-- | lib/Service/RunningService.php | 31 | ||||
-rw-r--r-- | lib/Service/SearchService.php | 22 | ||||
-rw-r--r-- | lib/Service/SettingsService.php | 23 | ||||
-rw-r--r-- | lib/Service/TestService.php | 17 |
10 files changed, 227 insertions, 140 deletions
diff --git a/lib/Service/CliService.php b/lib/Service/CliService.php index 4ae6bde..1b8b734 100644 --- a/lib/Service/CliService.php +++ b/lib/Service/CliService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,12 +27,20 @@ * */ + namespace OCA\FullTextSearch\Service; + use OCA\FullTextSearch\Model\Runner; use Symfony\Component\Console\Helper\ProgressBar; use Symfony\Component\Console\Output\OutputInterface; + +/** + * Class CliService + * + * @package OCA\FullTextSearch\Service + */ class CliService { @@ -51,8 +62,9 @@ class CliService { /** @var OutputInterface */ private $output = null; + /** - * TestService constructor. + * CliService constructor. * * @param MiscService $miscService */ @@ -75,7 +87,7 @@ class CliService { * @param string $panelId * @param array $lines */ - public function createPanel($panelId, $lines) { + public function createPanel(string $panelId, array $lines) { if (!is_array($lines)) { $lines = [$lines]; } @@ -96,7 +108,7 @@ class CliService { * @param string $panelSlot * @param string $panelId */ - public function displayPanel($panelSlot, $panelId) { + public function displayPanel(string $panelSlot, string $panelId) { $this->displayedPanel[] = [ 'slot' => $panelSlot, 'id' => $panelId @@ -109,7 +121,7 @@ class CliService { * * @return string */ - public function currentPanel($panelSlot) { + public function currentPanel(string $panelSlot): string { foreach ($this->displayedPanel as $panel) { if ($panel['slot'] === $panelSlot) { return $panel['id']; @@ -124,7 +136,7 @@ class CliService { * @param string $panelSlot * @param string $panelId */ - public function switchPanel($panelSlot, $panelId) { + public function switchPanel(string $panelSlot, string $panelId) { $this->displayedPanel = array_map( function($item) use ($panelId, $panelSlot) { if ($item['slot'] === $panelSlot) { @@ -167,6 +179,9 @@ class CliService { } + /** + * + */ public function refreshDisplay() { if ($this->display === null) { @@ -187,6 +202,9 @@ class CliService { } + /** + * + */ public function refreshInfo() { if ($this->runner->isPauseRunning()) { $this->display->setMessage('(paused)', '_paused'); @@ -200,7 +218,7 @@ class CliService { /** * @param array $info */ - public function onInfoUpdated($info) { + public function onInfoUpdated(array $info) { if ($this->display === null) { return; } @@ -215,3 +233,4 @@ class CliService { } } + diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index 2d5f119..614cd48 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,21 +27,31 @@ * */ + namespace OCA\FullTextSearch\Service; + use OCA\FullTextSearch\AppInfo\Application; use OCA\FullTextSearch\Exceptions\ProviderOptionsDoesNotExistException; use OCP\IConfig; use OCP\PreConditionNotMetException; use OCP\Util; + +/** + * Class ConfigService + * + * @package OCA\FullTextSearch\Service + */ class ConfigService { + const APP_NAVIGATION = 'app_navigation'; const SEARCH_PLATFORM = 'search_platform'; const PROVIDER_INDEXED = 'provider_indexed'; const CRON_LAST_ERR_RESET = 'cron_err_reset'; + /** @var array */ public $defaults = [ self::SEARCH_PLATFORM => '', @@ -47,6 +60,7 @@ class ConfigService { self::CRON_LAST_ERR_RESET => '0' ]; + /** @var IConfig */ private $config; @@ -65,7 +79,7 @@ class ConfigService { * @param MiscService $miscService */ public function __construct( - IConfig $config, $userId, MiscService $miscService + IConfig $config, string $userId, MiscService $miscService ) { $this->config = $config; $this->userId = $userId; @@ -76,7 +90,7 @@ class ConfigService { /** * @return array */ - public function getConfig() { + public function getConfig(): array { $keys = array_keys($this->defaults); $data = []; @@ -91,7 +105,7 @@ class ConfigService { /** * @param array $save */ - public function setConfig($save) { + public function setConfig(array $save) { $keys = array_keys($this->defaults); foreach ($keys as $k) { @@ -121,7 +135,7 @@ class ConfigService { * * @return string */ - public function getAppValue($key) { + public function getAppValue(string $key): string { $defaultValue = null; if (array_key_exists($key, $this->defaults)) { $defaultValue = $this->defaults[$key]; @@ -135,10 +149,8 @@ class ConfigService { * * @param string $key * @param string $value - * - * @return void */ - public function setAppValue($key, $value) { + public function setAppValue(string $key, string $value) { $this->config->setAppValue(Application::APP_NAME, $key, $value); } @@ -146,11 +158,9 @@ class ConfigService { * remove a key * * @param string $key - * - * @return string */ - public function deleteAppValue($key) { - return $this->config->deleteAppValue(Application::APP_NAME, $key); + public function deleteAppValue(string $key) { + $this->config->deleteAppValue(Application::APP_NAME, $key); } /** @@ -160,7 +170,7 @@ class ConfigService { * * @return string */ - public function getUserValue($key) { + public function getUserValue(string $key): string { $defaultValue = null; if (array_key_exists($key, $this->defaults)) { $defaultValue = $this->defaults[$key]; @@ -177,11 +187,10 @@ class ConfigService { * @param string $key * @param string $value * - * @return string * @throws PreConditionNotMetException */ - public function setUserValue($key, $value) { - return $this->config->setUserValue($this->userId, Application::APP_NAME, $key, $value); + public function setUserValue(string $key, string $value) { + $this->config->setUserValue($this->userId, Application::APP_NAME, $key, $value); } /** @@ -192,7 +201,7 @@ class ConfigService { * * @return string */ - public function getValueForUser($userId, $key) { + public function getValueForUser(string $userId, string $key) { return $this->config->getUserValue($userId, Application::APP_NAME, $key); } @@ -206,8 +215,8 @@ class ConfigService { * @return string * @throws PreConditionNotMetException */ - public function setValueForUser($userId, $key, $value) { - return $this->config->setUserValue($userId, Application::APP_NAME, $key, $value); + public function setValueForUser(string $userId, string $key, string $value) { + $this->config->setUserValue($userId, Application::APP_NAME, $key, $value); } @@ -216,7 +225,7 @@ class ConfigService { * @param string $options * @param string $value */ - public function setProviderOptions($providerId, $options, $value) { + public function setProviderOptions(string $providerId, string $options, string $value) { $arr = json_decode($this->getAppValue($options), true); if ($arr === null) { $arr = []; @@ -231,7 +240,7 @@ class ConfigService { /** * @param string $options */ - public function resetProviderOptions($options) { + public function resetProviderOptions(string $options) { $this->setAppValue($options, ''); } @@ -243,7 +252,7 @@ class ConfigService { * @return string * @throws ProviderOptionsDoesNotExistException */ - public function getProviderOptions($providerId, $options) { + public function getProviderOptions(string $providerId, string $options): string { $arr = json_decode($this->getAppValue($options), true); if ($arr === null) { $arr = []; @@ -259,19 +268,12 @@ class ConfigService { /** * return the cloud version. - * if $complete is true, return a string x.y.z - * - * @param boolean $complete * - * @return string|integer + * @return int */ - public function getCloudVersion($complete = false) { + public function getCloudVersion(): int { $ver = Util::getVersion(); - if ($complete) { - return implode('.', $ver); - } - return $ver[0]; } } diff --git a/lib/Service/IndexService.php b/lib/Service/IndexService.php index 6972eb9..fd37629 100644 --- a/lib/Service/IndexService.php +++ b/lib/Service/IndexService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,8 +27,10 @@ * */ + namespace OCA\FullTextSearch\Service; + use Exception; use OCA\FullTextSearch\Db\IndexesRequest; use OCA\FullTextSearch\Exceptions\DatabaseException; @@ -43,8 +48,15 @@ use OCP\FullTextSearch\Model\IndexDocument; use OCP\FullTextSearch\Model\IRunner; use OCP\FullTextSearch\Service\IIndexService; + +/** + * Class IndexService + * + * @package OCA\FullTextSearch\Service + */ class IndexService implements IIndexService { + /** @var IndexesRequest */ private $indexesRequest; @@ -150,7 +162,8 @@ class IndexService implements IIndexService { * @throws Exception */ public function indexProviderContentFromUser( - IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, $userId, $options + IFullTextSearchPlatform $platform, IFullTextSearchProvider $provider, string $userId, + IndexOptions $options ) { $this->updateRunnerAction('generateIndex' . $provider->getName()); $this->updateRunnerInfoArray( @@ -190,7 +203,7 @@ class IndexService implements IIndexService { */ private function updateDocumentsWithCurrIndex( IFullTextSearchProvider $provider, array $documents, IIndexOptions $options - ) { + ): array { $currIndex = $this->getProviderIndexFromProvider($provider->getId()); $result = []; $count = 0; @@ -198,7 +211,7 @@ class IndexService implements IIndexService { if ($count % 1000 === 0) { $this->updateRunnerAction('compareWithCurrentIndex', true); - $this->updateRunnerInfo('documentCurrent', $count); + $this->updateRunnerInfo('documentCurrent', (string)$count); } $count++; @@ -214,13 +227,13 @@ class IndexService implements IIndexService { continue; } - if ($options->getOption('force', false) === true) { + if ($options->getOptionBool('force', false) === true) { $index->setStatus(Index::INDEX_FULL); } $index->resetErrors(); $document->setIndex($index); - if ($options->getOption('force', false) === true + if ($options->getOptionBool('force', false) === true || !$this->isDocumentUpToDate($provider, $document)) { $result[] = $document; } @@ -237,7 +250,7 @@ class IndexService implements IIndexService { * @return bool */ private function isDocumentUpToDate(IFullTextSearchProvider $provider, IndexDocument $document - ) { + ): bool { $index = $document->getIndex(); if (!$index->isStatus(Index::INDEX_OK)) { @@ -257,7 +270,7 @@ class IndexService implements IIndexService { * * @return ProviderIndexes */ - private function getProviderIndexFromProvider(string $providerId) { + private function getProviderIndexFromProvider(string $providerId): ProviderIndexes { $indexes = $this->indexesRequest->getIndexesFromProvider($providerId); return new ProviderIndexes($indexes); @@ -343,7 +356,8 @@ class IndexService implements IIndexService { * @return IIndex * @throws Exception */ - public function indexDocument(IFullTextSearchPlatform $platform, $document) { + public function indexDocument(IFullTextSearchPlatform $platform, IndexDocument $document + ): IIndex { $this->updateRunnerAction('indexDocument', true); $this->updateRunnerInfoArray( [ @@ -369,7 +383,6 @@ class IndexService implements IIndexService { * @param IFullTextSearchProvider $provider * @param Index $index * - * @internal param int|string $documentId * @throws Exception */ public function updateDocument( @@ -463,6 +476,9 @@ class IndexService implements IIndexService { } + /** + * @param IIndex $index + */ private function updateIndexError(IIndex $index) { } @@ -556,7 +572,7 @@ class IndexService implements IIndexService { /** * @return Index[] */ - public function getErrorIndexes() { + public function getErrorIndexes(): array { return $this->indexesRequest->getErrorIndexes(); } @@ -578,7 +594,7 @@ class IndexService implements IIndexService { * * @return Index[] */ - public function getQueuedIndexes($all = false) { + public function getQueuedIndexes(bool $all = false): array { return $this->indexesRequest->getQueuedIndexes($all); } @@ -588,7 +604,7 @@ class IndexService implements IIndexService { * * @throws Exception */ - public function resetIndex($providerId = '') { + public function resetIndex(string $providerId = '') { $wrapper = $this->platformService->getPlatform(); $platform = $wrapper->getPlatform(); diff --git a/lib/Service/MiscService.php b/lib/Service/MiscService.php index c5b0d34..c8a608c 100644 --- a/lib/Service/MiscService.php +++ b/lib/Service/MiscService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,82 +27,48 @@ * */ + namespace OCA\FullTextSearch\Service; + use OCA\FullTextSearch\AppInfo\Application; use OCP\ILogger; use OCP\Util; + +/** + * Class MiscService + * + * @package OCA\FullTextSearch\Service + */ class MiscService { /** @var ILogger */ private $logger; - public function __construct(ILogger $logger) { - $this->logger = $logger; - } - - public function log($message, $level = 2) { - $data = array( - 'app' => Application::APP_NAME, - 'level' => $level - ); - - $this->logger->log($level, $message, $data); - } /** - * @param $arr - * @param $k + * MiscService constructor. * - * @param string $default - * - * @return array|string|integer + * @param ILogger $logger */ - public static function get($k, $arr, $default = '') { - if ($arr === null) { - return $default; - } - - if (!key_exists($k, $arr)) { - return $default; - } - - return $arr[$k]; - } - - - public static function noEndSlash($path) { - if (substr($path, -1) === '/') { - $path = substr($path, 0, -1); - } - - return $path; + public function __construct(ILogger $logger) { + $this->logger = $logger; } /** - * @param string $time - * - * @return float + * @param string $message + * @param int $level */ - public static function getMicroTime($time) { - list($usec, $sec) = explode(' ', $time); - - return ((float)$usec + (float)$sec); - } - + public function log(string $message, int $level = 2) { + $data = array( + 'app' => Application::APP_NAME, + 'level' => $level + ); - public function addJavascript() { - Util::addStyle(Application::APP_NAME, 'fulltextsearch'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.api'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.settings'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.searchbox'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.result'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1.navigation'); - Util::addScript(Application::APP_NAME, 'fulltextsearch.v1'); + $this->logger->log($level, $message, $data); } - } diff --git a/lib/Service/PlatformService.php b/lib/Service/PlatformService.php index 44cd71e..4738f80 100644 --- a/lib/Service/PlatformService.php +++ b/lib/Service/PlatformService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,8 +27,10 @@ * */ + namespace OCA\FullTextSearch\Service; + use Exception; use OC\App\AppManager; use OCA\FullTextSearch\Exceptions\PlatformDoesNotExistException; @@ -35,8 +40,15 @@ use OCA\FullTextSearch\Model\PlatformWrapper; use OCP\AppFramework\QueryException; use OCP\FullTextSearch\IFullTextSearchPlatform; + +/** + * Class PlatformService + * + * @package OCA\FullTextSearch\Service + */ class PlatformService { + /** @var AppManager */ private $appManager; @@ -62,7 +74,6 @@ class PlatformService { * @param AppManager $appManager * @param ConfigService $configService * @param MiscService $miscService - * */ public function __construct( AppManager $appManager, ConfigService $configService, MiscService $miscService @@ -80,7 +91,7 @@ class PlatformService { * @return PlatformWrapper * @throws Exception */ - public function getPlatform($silent = false) { + public function getPlatform(bool $silent = false): PlatformWrapper { try { $this->loadPlatform(); } catch (Exception $e) { @@ -98,7 +109,7 @@ class PlatformService { * @return PlatformWrapper[] * @throws Exception */ - public function getPlatforms() { + public function getPlatforms(): array { $this->loadPlatforms(); $platforms = []; @@ -201,7 +212,7 @@ class PlatformService { /** * @param string $appId */ - private function loadPlatformsFromApp($appId) { + private function loadPlatformsFromApp(string $appId) { $appInfo = $this->appManager->getAppInfo($appId); if (!is_array($appInfo) || !key_exists('fulltextsearch', $appInfo) || !key_exists('platform', $appInfo['fulltextsearch'])) { diff --git a/lib/Service/ProviderService.php b/lib/Service/ProviderService.php index 691e3d3..6cb5608 100644 --- a/lib/Service/ProviderService.php +++ b/lib/Service/ProviderService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,8 +27,10 @@ * */ + namespace OCA\FullTextSearch\Service; + use Exception; use OC\App\AppManager; use OCA\FullTextSearch\AppInfo\Application; @@ -40,8 +45,14 @@ use OCP\FullTextSearch\Service\IProviderService; use OCP\Util; +/** + * Class ProviderService + * + * @package OCA\FullTextSearch\Service + */ class ProviderService implements IProviderService { + /** @var AppManager */ private $appManager; @@ -64,7 +75,6 @@ class ProviderService implements IProviderService { * @param AppManager $appManager * @param ConfigService $configService * @param MiscService $miscService - * */ public function __construct( AppManager $appManager, ConfigService $configService, MiscService $miscService @@ -106,7 +116,7 @@ class ProviderService implements IProviderService { * @throws ProviderIsNotUniqueException * @throws QueryException */ - public function loadProvider($appId, $providerId) { + public function loadProvider(string $appId, string $providerId) { $provider = \OC::$server->query((string)$providerId); if (!($provider instanceof IFullTextSearchProvider)) { @@ -131,7 +141,7 @@ class ProviderService implements IProviderService { * @return ProviderWrapper[] * @throws Exception */ - public function getProviders() { + public function getProviders(): array { $this->loadProviders(); return $this->providers; @@ -141,7 +151,7 @@ class ProviderService implements IProviderService { * @return IFullTextSearchProvider[] * @throws Exception */ - public function getConfiguredProviders() { + public function getConfiguredProviders(): array { $this->loadProviders(); $providers = []; @@ -163,7 +173,7 @@ class ProviderService implements IProviderService { * @throws Exception * @throws ProviderDoesNotExistException */ - public function getFilteredProviders($providerList) { + public function getFilteredProviders(array $providerList): array { $this->loadProviders(); $providers = $this->getConfiguredProviders(); @@ -190,7 +200,7 @@ class ProviderService implements IProviderService { * @throws Exception * @throws ProviderDoesNotExistException */ - public function getProvider($providerId) { + public function getProvider(string $providerId): ProviderWrapper { $providers = $this->getProviders(); foreach ($providers as $providerWrapper) { @@ -209,7 +219,7 @@ class ProviderService implements IProviderService { * * @return bool */ - public function isProviderIndexed(string $providerId) { + public function isProviderIndexed(string $providerId): bool { try { $indexed = $this->configService->getProviderOptions( $providerId, ConfigService::PROVIDER_INDEXED @@ -227,13 +237,20 @@ class ProviderService implements IProviderService { } - public function setProviderAsIndexed(IFullTextSearchProvider $provider, $boolean) { + /** + * @param IFullTextSearchProvider $provider + * @param bool $boolean + */ + public function setProviderAsIndexed(IFullTextSearchProvider $provider, bool $boolean) { $this->configService->setProviderOptions( $provider->getId(), ConfigService::PROVIDER_INDEXED, (($boolean) ? '1' : '0') ); } + /** + * + */ public function setProvidersAsNotIndexed() { $this->configService->resetProviderOptions(ConfigService::PROVIDER_INDEXED); } @@ -246,7 +263,7 @@ class ProviderService implements IProviderService { * @throws ProviderIsNotUniqueException * @throws QueryException */ - private function loadProvidersFromApp($appId) { + private function loadProvidersFromApp(string $appId) { $appInfo = $this->appManager->getAppInfo($appId); if (!is_array($appInfo) || !key_exists('fulltextsearch', $appInfo) || !key_exists('provider', $appInfo['fulltextsearch'])) { @@ -254,19 +271,23 @@ class ProviderService implements IProviderService { } $providers = $appInfo['fulltextsearch']['provider']; + if (!is_array($providers)) { + $providers = [$providers]; + } + $this->loadProvidersFromList($appId, $providers); } /** * @param string $appId - * @param string|array $providers + * @param array $providers * * @throws ProviderIsNotCompatibleException * @throws ProviderIsNotUniqueException * @throws QueryException */ - private function loadProvidersFromList($appId, $providers) { + private function loadProvidersFromList(string $appId, array $providers) { if (!is_array($providers)) { $providers = [$providers]; } @@ -300,7 +321,7 @@ class ProviderService implements IProviderService { * * @return array */ - public function serialize($providers) { + public function serialize(array $providers): array { $arr = []; foreach ($providers as $provider) { $arr[] = [ diff --git a/lib/Service/RunningService.php b/lib/Service/RunningService.php index 3fe35c4..0527a63 100644 --- a/lib/Service/RunningService.php +++ b/lib/Service/RunningService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,8 +27,10 @@ * */ + namespace OCA\FullTextSearch\Service; + use OCA\FullTextSearch\Db\TickRequest; use OCA\FullTextSearch\Exceptions\RunnerAlreadyUpException; use OCA\FullTextSearch\Exceptions\TickDoesNotExistException; @@ -33,8 +38,15 @@ use OCA\FullTextSearch\Exceptions\TickIsNotAliveException; use OCA\FullTextSearch\Model\Tick; use OCA\FullTextSearch\Model\Runner; + +/** + * Class RunningService + * + * @package OCA\FullTextSearch\Service + */ class RunningService { + /** @var TickRequest */ private $tickRequest; @@ -62,13 +74,13 @@ class RunningService { /** - * @param $source + * @param string $source * * @return int * @throws RunnerAlreadyUpException * @throws \Exception */ - public function start($source) { + public function start(string $source): int { if ($this->isAlreadyRunning()) { throw new RunnerAlreadyUpException('Index is already running'); @@ -91,7 +103,7 @@ class RunningService { * @throws TickDoesNotExistException * @throws TickIsNotAliveException */ - public function update($runId, $action = '') { + public function update(int $runId, string $action = '') { $tick = $this->tickRequest->getTickById($runId); $this->isStillAlive($tick, true); @@ -107,11 +119,12 @@ class RunningService { /** * @deprecated - verifier l'interet ! + * * @param int $runId * @param string $reason * @param bool $stop */ - public function exception($runId, $reason, $stop = false) { + public function exception(int $runId, string $reason, bool $stop = false) { if ($stop) { try { $this->stop($runId, $reason); @@ -146,12 +159,12 @@ class RunningService { /** - * @param $runId + * @param int $runId * * @return bool * @throws TickIsNotAliveException */ - public function isAlive($runId) { + public function isAlive(int $runId): bool { $tick = null; try { $tick = $this->tickRequest->getTickById($runId); @@ -170,7 +183,7 @@ class RunningService { * @return bool * @throws TickIsNotAliveException */ - public function isStillAlive(Tick $tick, $exception = false) { + public function isStillAlive(Tick $tick, bool $exception = false): bool { if ($tick->getStatus() !== 'run') { if ($exception) { throw new TickIsNotAliveException(); @@ -186,7 +199,7 @@ class RunningService { /** * @return bool */ - public function isAlreadyRunning() { + public function isAlreadyRunning(): bool { $ticks = $this->tickRequest->getTicksByStatus('run'); $isAlreadyRunning = false; @@ -220,7 +233,7 @@ class RunningService { * @param Tick $tick * @param string $action */ - private function assignActionToTick(Tick &$tick, $action) { + private function assignActionToTick(Tick &$tick, string $action) { $now = microtime(true); $preAction = $tick->getAction(); diff --git a/lib/Service/SearchService.php b/lib/Service/SearchService.php index 5dc489d..db36ed9 100644 --- a/lib/Service/SearchService.php +++ b/lib/Service/SearchService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,8 +27,10 @@ * */ + namespace OCA\FullTextSearch\Service; + use Exception; use OC\App\AppManager; use OC\User\NoUserException; @@ -45,8 +50,14 @@ use OCP\IUser; use OCP\IUserManager; +/** + * Class SearchService + * + * @package OCA\FullTextSearch\Service + */ class SearchService implements ISearchService { + /** @var string */ private $userId; @@ -73,7 +84,7 @@ class SearchService implements ISearchService { /** - * IndexService constructor. + * SearchService constructor. * * @param string $userId * @param AppManager $appManager @@ -85,7 +96,8 @@ class SearchService implements ISearchService { * @param MiscService $miscService */ public function __construct( - $userId, AppManager $appManager, IUserManager $userManager, IGroupManager $groupManager, + string $userId, AppManager $appManager, IUserManager $userManager, + IGroupManager $groupManager, ConfigService $configService, ProviderService $providerService, PlatformService $platformService, MiscService $miscService @@ -177,9 +189,9 @@ class SearchService implements ISearchService { * @return ISearchResult[] */ private function searchFromProviders( - IFullTextSearchPlatform $platform, $providers, DocumentAccess $access, + IFullTextSearchPlatform $platform, array $providers, DocumentAccess $access, SearchRequest $request - ) { + ): array { $result = []; foreach ($providers AS $provider) { $provider->improveSearchRequest($request); @@ -203,7 +215,7 @@ class SearchService implements ISearchService { * * @return DocumentAccess */ - private function getDocumentAccessFromUser(IUser $user) { + private function getDocumentAccessFromUser(IUser $user): DocumentAccess { $rights = new DocumentAccess(); $rights->setViewerId($user->getUID()); diff --git a/lib/Service/SettingsService.php b/lib/Service/SettingsService.php index 939db0f..e6b7353 100644 --- a/lib/Service/SettingsService.php +++ b/lib/Service/SettingsService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,12 +27,21 @@ * */ + namespace OCA\FullTextSearch\Service; + use Exception; + +/** + * Class SettingsService + * + * @package OCA\FullTextSearch\Service + */ class SettingsService { + /** @var PlatformService */ private $platformService; @@ -39,6 +51,7 @@ class SettingsService { /** @var MiscService */ private $miscService; + /** * SettingsService constructor. * @@ -57,11 +70,11 @@ class SettingsService { /** - * @param $data + * @param array $data * * @return bool */ - public function checkConfig($data) { + public function checkConfig(array $data): bool { return true; } @@ -71,7 +84,7 @@ class SettingsService { * * @throws Exception */ - public function completeSettings(&$data) { + public function completeSettings(array &$data) { $data = array_merge( $data, [ 'platforms_all' => $this->completeSettingsPlatforms(), @@ -86,7 +99,7 @@ class SettingsService { * @return array * @throws Exception */ - private function completeSettingsPlatforms() { + private function completeSettingsPlatforms(): array { $list = []; $platforms = $this->platformService->getPlatforms(); foreach ($platforms as $wrapper) { @@ -105,7 +118,7 @@ class SettingsService { * @return array * @throws Exception */ - private function completeSettingsProviders() { + private function completeSettingsProviders(): array { $list = []; $providers = $this->providerService->getProviders(); foreach ($providers as $providerWrapper) { diff --git a/lib/Service/TestService.php b/lib/Service/TestService.php index f362d88..469933a 100644 --- a/lib/Service/TestService.php +++ b/lib/Service/TestService.php @@ -1,4 +1,7 @@ <?php +declare(strict_types=1); + + /** * FullTextSearch - Full text search framework for Nextcloud * @@ -24,13 +27,21 @@ * */ + namespace OCA\FullTextSearch\Service; + use OCA\FullTextSearch\Provider\TestProvider; use OCP\FullTextSearch\Model\DocumentAccess; use OCP\FullTextSearch\Model\IIndexOptions; use OCP\FullTextSearch\Model\IndexDocument; + +/** + * Class TestService + * + * @package OCA\FullTextSearch\Service + */ class TestService { const DOCUMENT_USER1 = 'user1'; @@ -69,7 +80,7 @@ class TestService { * * @return IndexDocument */ - public function generateIndexDocumentContentLicense(IIndexOptions $options) { + public function generateIndexDocumentContentLicense(IIndexOptions $options): IndexDocument { $indexDocument = $this->generateIndexDocument(self::DOCUMENT_TYPE_LICENSE); $content = file_get_contents(__DIR__ . '/../../LICENSE'); @@ -96,7 +107,7 @@ class TestService { * * @return IndexDocument */ - public function generateIndexDocumentSimple(IIndexOptions $options) { + public function generateIndexDocumentSimple(IIndexOptions $options): IndexDocument { $indexDocument = $this->generateIndexDocument(self::DOCUMENT_TYPE_SIMPLE); $indexDocument->setContent('document is a simple test'); @@ -141,7 +152,7 @@ class TestService { * * @return IndexDocument */ - private function generateIndexDocument($documentType) { + private function generateIndexDocument(string $documentType): IndexDocument { $indexDocument = new IndexDocument(TestProvider::TEST_PROVIDER_ID, $documentType); $access = new DocumentAccess(self::DOCUMENT_USER1); |