FluentDocumentExtension   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBeforeAddDoc() 0 7 2
1
<?php
2
/**
3
 * Class FluentDocumentExtension|Firesphere\SolrFluent\Extensions\FluentDocumentExtension Add Fluent filtering
4
 * to queries
5
 *
6
 * @package Firesphere\Solr\Fluent
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\Solr\Fluent
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
        /** @var string $locale */
37 1
        $locale = $fluentState->getLocale();
38 1
        if ($locale) {
39 1
            $field['name'] .= '_' . $locale;
40
        }
41 1
    }
42
}
43