Passed
Push — sheepy/elevation-configuration ( bdeab0...bcf7bc )
by Marco
18:34
created

GetSetSchemaServiceTrait   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 121
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
eloc 20
c 1
b 0
f 0
dl 0
loc 121
rs 10

11 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemplate() 0 3 1
A getIndex() 0 3 1
A setStore() 0 3 1
A setTypesTemplate() 0 5 1
A setIndex() 0 8 1
A getIDField() 0 3 1
A getIndexName() 0 3 1
A getDefaultField() 0 3 1
A getClassID() 0 3 1
A getTypesTemplate() 0 3 1
A setTemplate() 0 5 1
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Traits;
5
6
use Firesphere\SolrSearch\Indexes\BaseIndex;
7
use Firesphere\SolrSearch\Services\SchemaService;
8
use Firesphere\SolrSearch\Services\SolrCoreService;
9
10
trait GetSetSchemaServiceTrait
11
{
12
    /**
13
     * @var string ABSOLUTE Path to template
14
     */
15
    protected $template;
16
    /**
17
     * @var bool
18
     */
19
    protected $store = false;
20
    /**
21
     * @var BaseIndex
22
     */
23
    protected $index;
24
    /**
25
     * @var string ABSOLUTE Path to types.ss template
26
     */
27
    protected $typesTemplate;
28
29
    /**
30
     * @param bool $store
31
     */
32
    public function setStore(bool $store): void
33
    {
34
        $this->store = $store;
35
    }
36
37
    /**
38
     * @return BaseIndex
39
     */
40
    public function getIndex()
41
    {
42
        return $this->index;
43
    }
44
45
    /**
46
     * @param BaseIndex $index
47
     * @return SchemaService
48
     */
49
    public function setIndex($index): self
50
    {
51
        $this->index = $index;
52
        // Add the index to the introspection as well, there's no need for a separate call here
53
        // We're loading this core, why would we want the introspection from a different index?
54
        $this->introspection->setIndex($index);
55
56
        return $this;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getIndexName(): string
63
    {
64
        return $this->index->getIndexName();
65
    }
66
67
    /**
68
     * @return string|array
69
     */
70
    public function getDefaultField()
71
    {
72
        return $this->index->getDefaultField();
73
    }
74
75
    /**
76
     * Get the Identifier Field for Solr
77
     *
78
     * @return string
79
     */
80
    public function getIDField(): string
81
    {
82
        return SolrCoreService::ID_FIELD;
83
    }
84
85
    /**
86
     * Get the Identifier Field for Solr
87
     *
88
     * @return string
89
     */
90
    public function getClassID(): string
91
    {
92
        return SolrCoreService::CLASS_ID_FIELD;
93
    }
94
95
    /**
96
     * @return string
97
     */
98
    public function getTypesTemplate()
99
    {
100
        return $this->typesTemplate;
101
    }
102
103
    /**
104
     * @param string $typesTemplate
105
     * @return SchemaService
106
     */
107
    public function setTypesTemplate($typesTemplate): self
108
    {
109
        $this->typesTemplate = $typesTemplate;
110
111
        return $this;
112
    }
113
114
    /**
115
     * @return string
116
     */
117
    public function getTemplate()
118
    {
119
        return $this->template;
120
    }
121
122
    /**
123
     * @param string $template
124
     * @return SchemaService
125
     */
126
    public function setTemplate($template): self
127
    {
128
        $this->template = $template;
129
130
        return $this;
131
    }
132
}
133