diff options
Diffstat (limited to 'lib/Service/MiscService.php')
-rw-r--r-- | lib/Service/MiscService.php | 77 |
1 files changed, 23 insertions, 54 deletions
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); } - } |