Passed
Push — master ( f22d02...bed8f0 )
by Simon
05:40 queued 03:47
created

FluentDocumentExtension::onBeforeAddDoc()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
ccs 5
cts 5
cp 1
crap 2
1
<?php
2
/**
3
 * Class FluentDocumentExtension|Firesphere\SolrFluent\Extensions\FluentDocumentExtension Add Fluent filtering
4
 * to queries
5
 *
6
 * @package Firesphere\SolrFluent\Extensions
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace Firesphere\SolrFluent\Extensions;
12
13
use Firesphere\SolrSearch\Factories\DocumentFactory;
14
use SilverStripe\Core\Extension;
15
use TractorCow\Fluent\State\FluentState;
16
17
/**
18
 * Class Firesphere\SolrFluent\Extensions\FluentDocumentExtension
19
 *
20
 * Update Documents per locale
21
 *
22
 * @package Firesphere\SolrFluent\Extensions
23
 * @property DocumentFactory|FluentDocumentExtension $owner
24
 */
25
class FluentDocumentExtension extends Extension
26
{
27
    /**
28
     * Update the Solr field for the value to use the locale name
29
     *
30
     * @param array $field
31
     * @param string $value
32
     */
33 1
    public function onBeforeAddDoc(&$field, &$value): void
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

33
    public function onBeforeAddDoc(&$field, /** @scrutinizer ignore-unused */ &$value): void

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35 1
        $fluentState = FluentState::singleton();
36 1
        $locale = $fluentState->getLocale();
37 1
        if ($locale) {
38 1
            $field['name'] .= '_' . $locale;
39
        }
40 1
    }
41
}
42