Passed
Push — master ( c333a9...193f71 )
by Marcel
02:44
created

Provider19::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 3
dl 0
loc 7
rs 10
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-2020 Marcel Scherello
11
 * @copyright 2015 Sebastian Doell
12
 */
13
14
namespace OCA\audioplayer\Search;
15
16
use OCA\audioplayer\Controller\DbController;
17
use OCP\IL10N;
18
use OCP\IURLGenerator;
19
20
/**
21
 * Provide search results from the 'audioplayer' app
22
 */
23
class Provider19 extends \OCP\Search\Provider
24
{
25
26
    /** @var IL10N */
27
    private $l10n;
28
29
    /** @var IURLGenerator */
30
    private $urlGenerator;
31
32
    private $DBController;
33
34
    public function __construct(IL10N $l10n,
35
                                IURLGenerator $urlGenerator,
36
                                DBController $DBController)
37
    {
38
        $this->l10n = $l10n;
39
        $this->urlGenerator = $urlGenerator;
40
        $this->DBController = $DBController;
41
    }
42
43
    /**
44
     *
45
     * @param string $query
46
     * @return array
47
     */
48
    function search($query)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
49
    {
50
        $searchresults = array();
51
        $results = $this->DBController->search($query);
52
53
        foreach ($results as $result) {
54
            $returnData = array();
55
            $returnData['id'] = $result['id'];
56
            $returnData['description'] = $this->l10n->t('Audio Player') . ' - ' . $result['name'];
57
            $returnData['link'] = '../audioplayer/#' . $result['id'];
58
            $returnData['icon'] = '../audioplayer/img/app.svg';
59
60
            $searchresults[] = new \OCA\audioplayer\Search\Result($returnData);
61
        }
62
        return $searchresults;
63
    }
64
}
65