DocumentFactoryExtension::updateDefaultFields()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Class DocumentFactoryExtension|Firesphere\SolrPermissions\Extensions\DocumentFactoryExtension Update the documents
4
 * fields with the MemberView settings
5
 *
6
 * @package Firesphere\Solr\Permissions
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace Firesphere\SolrPermissions\Extensions;
12
13
use Firesphere\SolrSearch\Factories\DocumentFactory;
14
use SilverStripe\Core\Extension;
15
use SilverStripe\ORM\DataObject;
16
use Solarium\Core\Query\DocumentInterface;
17
18
/**
19
 * Class \Firesphere\SolrPermissions\Extensions\DocumentFactoryExtension
20
 *
21
 * Extension class to add the default MemberView field to the Solr document
22
 *
23
 * @package Firesphere\Solr\Permissions
24
 * @property DocumentFactory|DocumentFactoryExtension $owner
25
 */
26
class DocumentFactoryExtension extends Extension
27
{
28
29
    /**
30
     * Add the MemberView status to the default fields
31
     *
32
     * @param DocumentInterface $doc
33
     * @param DataObject|DataObjectExtension $item
34
     */
35 1
    public function updateDefaultFields(&$doc, $item)
36
    {
37 1
        $doc->addField('MemberView', $item->getMemberView());
0 ignored issues
show
Bug introduced by
The method addField() does not exist on Solarium\Core\Query\DocumentInterface. It seems like you code against a sub-type of Solarium\Core\Query\DocumentInterface such as Solarium\Plugin\MinimumScoreFilter\Document or Solarium\QueryType\Update\Query\Document. ( Ignorable by Annotation )

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

37
        $doc->/** @scrutinizer ignore-call */ 
38
              addField('MemberView', $item->getMemberView());
Loading history...
38 1
    }
39
}
40