Conditions | 7 |
Paths | 9 |
Total Lines | 26 |
Lines | 16 |
Ratio | 61.54 % |
Changes | 0 |
1 | <?php |
||
18 | public function handle(CriteriaConverter $converter, Criterion $criterion) |
||
19 | { |
||
20 | switch ($criterion->target) |
||
21 | { |
||
22 | View Code Duplication | case Criterion\UserMetadata::OWNER: |
|
|
|||
23 | $valueList = (array)$criterion->value; |
||
24 | |||
25 | foreach ($valueList as $value) { |
||
26 | $result[] = 'owner_id:' . $this->escapeValue($value); |
||
27 | } |
||
28 | |||
29 | return count($result) == 1 ? $result[0] : array_unshift($result, 'OR'); |
||
30 | |||
31 | View Code Duplication | case Criterion\UserMetadata::GROUP: |
|
32 | $valueList = (array)$criterion->value; |
||
33 | |||
34 | foreach ($valueList as $value) { |
||
35 | $result[] = 'owner_group_id:' . $this->escapeValue($value); |
||
36 | } |
||
37 | |||
38 | return count($result) == 1 ? $result[0] : array_unshift($result, 'OR'); |
||
39 | |||
40 | default: |
||
41 | throw new NotImplementedException("Can not convert UserMetadata criterion for target {$criterion->target}: no such data in the solr schema by default"); |
||
42 | } |
||
43 | } |
||
44 | } |
||
45 |
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.