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

MockSearchResultRepository::persist()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
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 Doctrine\Common\Collections\Criteria;
15
use Zikula\SearchModule\Entity\RepositoryInterface\SearchResultRepositoryInterface;
16
use Zikula\SearchModule\Entity\SearchResultEntity;
17
18
class MockSearchResultRepository implements SearchResultRepositoryInterface
19
{
20
    /**
21
     * @var SearchResultEntity[]
22
     */
23
    private $results = [];
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function countResults($sessionId = '')
29
    {
30
        $count = 0;
31
        foreach ($this->results as $k => $result) {
32
            if ($sessionId == $result->getSesid()) {
33
                $count++;
34
            }
35
        }
36
37
        return $count;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getResults($filters = [], $sorting = [], $limit = 0, $offset = 0)
44
    {
45
        return $this->results;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function clearOldResults($sessionId = '')
52
    {
53
        foreach ($this->results as $k => $result) {
54
            if ($sessionId == $result->getSesid()) {
55
                unset($this->results[$k]);
56
            }
57
        }
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function persist(SearchResultEntity $entity)
64
    {
65
        $this->results[] = $entity;
66
    }
67
68
    /**
69
     * {@inheritdoc}
70
     */
71
    public function flush(SearchResultEntity $entity = null)
72
    {
73
        // nothing
74
    }
75
76
    /**
77
     * {@inheritdoc}
78
     */
79
    public function find($id)
80
    {
81
        // TODO: Implement find() method.
82
    }
83
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function findAll()
88
    {
89
        // TODO: Implement findAll() method.
90
    }
91
92
    /**
93
     * {@inheritdoc}
94
     */
95
    public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
96
    {
97
        // TODO: Implement findBy() method.
98
    }
99
100
    /**
101
     * {@inheritdoc}
102
     */
103
    public function findOneBy(array $criteria)
104
    {
105
        // TODO: Implement findOneBy() method.
106
    }
107
108
    /**
109
     * {@inheritdoc}
110
     */
111
    public function getClassName()
112
    {
113
        // TODO: Implement getClassName() method.
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119
    public function matching(Criteria $criteria)
120
    {
121
        // TODO: Implement matching() method.
122
    }
123
}
124