Passed
Push — master ( f47e0d...d9327a )
by Simon
10:55 queued 52s
created

FluentDocumentExtension   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 14
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A onBeforeAddDoc() 0 6 2
1
<?php
2
3
4
namespace Firesphere\SolrFluent\Extensions;
5
6
use Firesphere\SolrSearch\Factories\DocumentFactory;
7
use SilverStripe\ORM\DataExtension;
8
use TractorCow\Fluent\State\FluentState;
9
10
/**
11
 * Class Firesphere\SolrFluent\Extensions\FluentDocumentExtension
12
 *
13
 * Update Documents per locale
14
 * @package Firesphere\SolrFluent\Extensions
15
 * @property DocumentFactory|FluentDocumentExtension $owner
16
 */
17
class FluentDocumentExtension extends DataExtension
18
{
19
    /**
20
     * Update the Solr field for the value to use the locale name
21
     *
22
     * @param array $field
23
     * @param string $value
24
     */
25
    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

25
    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...
26
    {
27
        $fluentState = FluentState::singleton();
28
        $locale = $fluentState->getLocale();
29
        if ($locale) {
30
            $field['name'] .= '_' . $locale;
31
        }
32
    }
33
34
}
35