Completed
Push — master ( ac63be...fbf3ff )
by Craig
06:34
created

SearchableBar::getBaseResult()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
eloc 8
nc 1
nop 0
dl 11
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the Zikula package.
5
 *
6
 * Copyright Zikula Foundation - http://zikula.org/
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Zikula\SearchModule\Tests\Api\Fixtures;
13
14
use Symfony\Component\Form\FormBuilderInterface;
15
use Zikula\Core\RouteUrl;
16
use Zikula\SearchModule\Entity\SearchResultEntity;
17
use Zikula\SearchModule\SearchableInterface;
18
19 View Code Duplication
class SearchableBar implements SearchableInterface
20
{
21
    /**
22
     * * {@inheritdoc}
23
     */
24
    public function amendForm(FormBuilderInterface $form)
25
    {
26
        // TODO: Implement amendForm() method.
27
    }
28
29
    /**
30
     * * {@inheritdoc}
31
     */
32
    public function getResults(array $words, $searchType = 'AND', $modVars = null)
33
    {
34
        $results = [];
35
        if (in_array('top', $words)) {
36
            $r = $this->getBaseResult();
37
            $r->setText(sprintf('ZikulaBarModule found using %s', implode(', ', $words)));
38
            $results[] = $r;
39
        }
40
41
        return $results;
42
    }
43
44
    /**
45
     * * {@inheritdoc}
46
     */
47
    public function getErrors()
48
    {
49
        return [];
50
    }
51
52
    private function getBaseResult()
53
    {
54
        $r = new SearchResultEntity();
55
        $r->setCreated(new \DateTime())
56
            ->setModule('ZikulaBarModule')
57
            ->setSesid('test')
58
            ->setTitle('ZikulaBarModule result')
59
            ->setUrl(RouteUrl::createFromRoute('zikulabarmodule_user_index'));
60
61
        return $r;
62
    }
63
}
64