Completed
Push — ezp-30616 ( 9239a0...7bf8e8 )
by
unknown
57:53 queued 37:56
created

SearchService   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 124
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 124
loc 124
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A findContent() 4 4 1
A findContentInfo() 4 4 1
A findSingle() 4 4 1
A suggest() 4 4 1
A findLocations() 4 4 1
A supports() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * SearchService class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
namespace eZ\Publish\Core\SignalSlot;
10
11
use eZ\Publish\API\Repository\SearchService as SearchServiceInterface;
12
use eZ\Publish\API\Repository\Values\Content\Query;
13
use eZ\Publish\API\Repository\Values\Content\LocationQuery;
14
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
15
16
/**
17
 * SearchService class.
18
 */
19 View Code Duplication
class SearchService implements SearchServiceInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * Aggregated service.
23
     *
24
     * @var \eZ\Publish\API\Repository\SearchService
25
     */
26
    protected $service;
27
28
    /**
29
     * SignalDispatcher.
30
     *
31
     * @var \eZ\Publish\Core\SignalSlot\SignalDispatcher
32
     */
33
    protected $signalDispatcher;
34
35
    /**
36
     * Constructor.
37
     *
38
     * Construct service object from aggregated service and signal
39
     * dispatcher
40
     *
41
     * @param \eZ\Publish\API\Repository\SearchService $service
42
     * @param \eZ\Publish\Core\SignalSlot\SignalDispatcher $signalDispatcher
43
     */
44
    public function __construct(SearchServiceInterface $service, SignalDispatcher $signalDispatcher)
45
    {
46
        $this->service = $service;
47
        $this->signalDispatcher = $signalDispatcher;
48
    }
49
50
    /**
51
     * Finds content objects for the given query.
52
     *
53
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
54
     *
55
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
56
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
57
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
58
     * @param bool $filterOnUserPermissions if true only the objects which the user is allowed to read are returned.
59
     *
60
     * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
61
     */
62
    public function findContent(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true)
63
    {
64
        return $this->service->findContent($query, $languageFilter, $filterOnUserPermissions);
65
    }
66
67
    /**
68
     * Finds contentInfo objects for the given query.
69
     *
70
     * @see SearchServiceInterface::findContentInfo()
71
     *
72
     * @since 5.4.5
73
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
74
     *
75
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
76
     * @param array $languageFilter - a map of filters for the returned fields.
77
     *        Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
78
     *                            useAlwaysAvailable defaults to true to avoid exceptions on missing translations.
79
     * @param bool $filterOnUserPermissions if true (default) only the objects which is the user allowed to read are returned.
80
     *
81
     * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
82
     */
83
    public function findContentInfo(Query $query, array $languageFilter = array(), $filterOnUserPermissions = true)
84
    {
85
        return $this->service->findContentInfo($query, $languageFilter, $filterOnUserPermissions);
86
    }
87
88
    /**
89
     * Performs a query for a single content object.
90
     *
91
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions
92
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if criterion is not valid
93
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is more than than one result matching the criterions
94
     *
95
     * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter
96
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
97
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
98
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
99
     *
100
     * @return \eZ\Publish\API\Repository\Values\Content\Content
101
     */
102
    public function findSingle(Criterion $filter, array $languageFilter = array(), $filterOnUserPermissions = true)
103
    {
104
        return $this->service->findSingle($filter, $languageFilter, $filterOnUserPermissions);
105
    }
106
107
    /**
108
     * Suggests a list of values for the given prefix.
109
     *
110
     * @param string $prefix
111
     * @param string[] $fieldPaths
112
     * @param int $limit
113
     * @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter
114
     */
115
    public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $filter = null)
116
    {
117
        return $this->service->suggest($prefix, $fieldPaths, $limit, $filter);
118
    }
119
120
    /**
121
     * Finds Locations for the given query.
122
     *
123
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if query is not valid
124
     *
125
     * @param \eZ\Publish\API\Repository\Values\Content\LocationQuery $query
126
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
127
     *        Currently supports: <code>array("languages" => array(<language1>,..), "useAlwaysAvailable" => bool)</code>
128
     *                            useAlwaysAvailable defaults to true to avoid exceptions on missing translations
129
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
130
     *
131
     * @return \eZ\Publish\API\Repository\Values\Content\Search\SearchResult
132
     */
133
    public function findLocations(LocationQuery $query, array $languageFilter = array(), $filterOnUserPermissions = true)
134
    {
135
        return $this->service->findLocations($query, $languageFilter, $filterOnUserPermissions);
136
    }
137
138
    public function supports($capabilityFlag)
139
    {
140
        return $this->service->supports($capabilityFlag);
141
    }
142
}
143