Passed
Pull Request — main (#67)
by Simon
01:40 queued 34s
created

BaseIndexTrait::setStoredFields()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 8
rs 10
1
<?php
2
/**
3
 * Trait BaseIndexTrait|Firesphere\ElasticSearch\Traits\BaseIndexTrait Used to extract methods from the
4
 * {@link \Firesphere\ElasticSearch\Indexes\ElasticIndex} to make the code more readable
5
 *
6
 * @package Firesphere\Elastic\Search
7
 * @author Simon `Firesphere` Erkelens; Marco `Sheepy` Hermo
8
 * @copyright Copyright (c) 2018 - now() Firesphere & Sheepy
9
 */
10
11
namespace Firesphere\ElasticSearch\Traits\IndexTraits;
12
13
/**
14
 * Trait ElasticIndexTrait
15
 * Getters and Setters for the ElasticIndex
16
 *
17
 * @package Firesphere\Elastic\Search
18
 */
19
trait BaseIndexTrait
20
{
21
    /**
22
     * @var array Fulltext fields
23
     */
24
    protected $fulltextFields = [];
25
    /**
26
     * @var array Filterable fields
27
     */
28
    protected $filterFields = [];
29
30
    /**
31
     * Add a single Fulltext field
32
     *
33
     * @param string $fulltextField
34
     * @param array $options
35
     * @return $this
36
     */
37
    public function addFulltextField($fulltextField, $options = []): self
0 ignored issues
show
Unused Code introduced by
The parameter $options 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

37
    public function addFulltextField($fulltextField, /** @scrutinizer ignore-unused */ $options = []): self

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...
38
    {
39
        $this->fulltextFields[] = $fulltextField;
40
41
        return $this;
42
    }
43
44
    /**
45
     * Add a filterable field
46
     * Compatibility stub for Solr
47
     *
48
     * @param $filterField
49
     * @return $this
50
     */
51
    public function addFilterField($filterField): self
52
    {
53
        $this->filterFields[] = $filterField;
54
        $this->addFulltextField($filterField);
55
56
        return $this;
57
    }
58
}
59