Passed
Pull Request — main (#67)
by Simon
02:33 queued 01:23
created

BaseIndexTrait::setFulltextFields()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
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
    /**
46
     * This trait requires classes to be set, so getClasses can be called.
47
     *
48
     * @return array
49
     */
50
    abstract public function getClasses(): array;
51
52
    /**
53
     * Add a filterable field
54
     * Compatibility stub for Solr
55
     *
56
     * @param $filterField
57
     * @return $this
58
     */
59
    public function addFilterField($filterField): self
60
    {
61
        $this->filterFields[] = $filterField;
62
        $this->addFulltextField($filterField);
63
64
        return $this;
65
    }
66
}
67