Provider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 19
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A search() 0 14 2
A __construct() 0 6 1
1
<?php
2
/**
3
 * Audio Player
4
 *
5
 * This file is licensed under the Affero General Public License version 3 or
6
 * later. See the LICENSE.md file.
7
 *
8
 * @author Marcel Scherello <[email protected]>
9
 * @author Sebastian Doell <[email protected]>
10
 * @copyright 2016-2019 Marcel Scherello
11
 * @copyright 2015 Sebastian Doell
12
 */
13
14
namespace OCA\audioplayer\Search;
15
use OCA\audioplayer\AppInfo\Application;
16
17
/**
18
 * Provide search results from the 'audioplayer' app
19
 */
20
class Provider extends \OCP\Search\Provider {
21
22
    private $DBController;
23
	private $l10n;
24
	private $app;
25
	
26
    public function __construct() {
27
		$app = new Application();
28
		$container = $app->getContainer();
29
		$this->app = $app;
30
        $this->DBController = $container->query(\OCA\audioplayer\Controller\DbController::class);
31
		$this->l10n = $container->query('L10N');
32
	}
33
34
    /**
35
     *
36
     * @param string $query
37
     * @return array
38
     */
39
	function search($query) {
40
		$searchresults = array();
41
        $results = $this->DBController->search($query);
42
		
43
		foreach($results as $result) {
44
			$returnData = array();
45
			$returnData['id'] = $result['id'];
46
			$returnData['description'] = $this->l10n->t('Audio Player').' - '.$result['name'];
47
			$returnData['link'] = '../audioplayer/#' . $result['id'];
48
			$returnData['icon'] = '../audioplayer/img/app.svg';
49
50
			$searchresults[] = new \OCA\audioplayer\Search\Result($returnData);
51
		}
52
		return $searchresults;
53
	}
54
}
55