Passed
Pull Request — master (#164)
by Simon
08:00 queued 05:45
created

SolrIndexTrait::setIndex()   A

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
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
4
namespace Firesphere\SolrSearch\Traits;
5
6
use Firesphere\SolrSearch\Indexes\BaseIndex;
7
use Firesphere\SolrSearch\Services\SolrCoreService;
8
use Firesphere\SolrSearch\Tasks\SolrIndexTask;
9
10
/**
11
 * Trait SolrIndexTrait
12
 * Getters and Setters for the SolrIndexTask
13
 *
14
 * @package Firesphere\SolrSearch\Traits
15
 */
16
trait SolrIndexTrait
17
{
18
    /**
19
     * Debug mode enabled, default false
20
     *
21
     * @var bool
22
     */
23
    protected $debug = false;
24
    /**
25
     * Singleton of {@link SolrCoreService}
26
     *
27
     * @var SolrCoreService
28
     */
29
    protected $service;
30
    /**
31
     * @var BaseIndex Current core being indexed
32
     */
33
    protected $index;
34
    /**
35
     * @var int Number of CPU cores available
36
     */
37
    protected $cores = 1;
38
    /**
39
     * Default batch length
40
     *
41
     * @var int
42
     */
43
    protected $batchLength = 1;
44
45
    /**
46
     * Set the {@link SolrCoreService}
47
     *
48
     * @param SolrCoreService $service
49
     * @return self
50
     */
51 15
    public function setService(SolrCoreService $service): self
52
    {
53 15
        $this->service = $service;
54
55 15
        return $this;
56
    }
57
58
    /**
59
     * Set the debug mode
60
     *
61
     * @param bool $debug
62
     * @return self
63
     */
64 15
    public function setDebug(bool $debug): self
65
    {
66 15
        $this->debug = $debug;
67
68 15
        return $this;
69
    }
70
71
    /**
72
     * @return BaseIndex
73
     */
74 14
    public function getIndex(): BaseIndex
75
    {
76 14
        return $this->index;
77
    }
78
79
    /**
80
     * @param BaseIndex $index
81
     */
82 14
    public function setIndex(BaseIndex $index): void
83
    {
84 14
        $this->index = $index;
85 14
    }
86
87
    /**
88
     * @return int
89
     */
90 1
    public function getCores(): int
91
    {
92 1
        return $this->cores;
93
    }
94
95
    /**
96
     * @param int $cores
97
     */
98 15
    public function setCores(int $cores): void
99
    {
100 15
        $this->cores = $cores;
101 15
    }
102
103
    /**
104
     * @return int
105
     */
106 13
    public function getBatchLength(): int
107
    {
108 13
        return $this->batchLength;
109
    }
110
111
    /**
112
     * @param int $batchLength
113
     */
114 15
    public function setBatchLength(int $batchLength): void
115
    {
116 15
        $this->batchLength = $batchLength;
117 15
    }
118
}
119