Total Complexity | 8 |
Total Lines | 101 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
15 | trait SolrIndexTrait |
||
16 | { |
||
17 | /** |
||
18 | * Debug mode enabled, default false |
||
19 | * |
||
20 | * @var bool |
||
21 | */ |
||
22 | protected $debug = false; |
||
23 | /** |
||
24 | * Singleton of {@link SolrCoreService} |
||
25 | * |
||
26 | * @var SolrCoreService |
||
27 | */ |
||
28 | protected $service; |
||
29 | /** |
||
30 | * @var BaseIndex Current core being indexed |
||
31 | */ |
||
32 | protected $index; |
||
33 | /** |
||
34 | * @var int Number of CPU cores available |
||
35 | */ |
||
36 | protected $cores = 1; |
||
37 | /** |
||
38 | * Default batch length |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $batchLength = 1; |
||
43 | |||
44 | /** |
||
45 | * Set the {@link SolrCoreService} |
||
46 | * |
||
47 | * @param SolrCoreService $service |
||
48 | * @return self |
||
49 | */ |
||
50 | 15 | public function setService(SolrCoreService $service): self |
|
51 | { |
||
52 | 15 | $this->service = $service; |
|
53 | |||
54 | 15 | return $this; |
|
55 | } |
||
56 | |||
57 | /** |
||
58 | * Set the debug mode |
||
59 | * |
||
60 | * @param bool $debug |
||
61 | * @return self |
||
62 | */ |
||
63 | 15 | public function setDebug(bool $debug): self |
|
64 | { |
||
65 | 15 | $this->debug = $debug; |
|
66 | |||
67 | 15 | return $this; |
|
68 | } |
||
69 | |||
70 | /** |
||
71 | * @return BaseIndex |
||
72 | */ |
||
73 | 14 | public function getIndex(): BaseIndex |
|
74 | { |
||
75 | 14 | return $this->index; |
|
76 | } |
||
77 | |||
78 | /** |
||
79 | * @param BaseIndex $index |
||
80 | */ |
||
81 | 14 | public function setIndex(BaseIndex $index): void |
|
82 | { |
||
83 | 14 | $this->index = $index; |
|
84 | 14 | } |
|
85 | |||
86 | /** |
||
87 | * @return int |
||
88 | */ |
||
89 | 3 | public function getCores(): int |
|
90 | { |
||
91 | 3 | return $this->cores; |
|
92 | } |
||
93 | |||
94 | /** |
||
95 | * @param int $cores |
||
96 | */ |
||
97 | 15 | public function setCores(int $cores): void |
|
98 | { |
||
99 | 15 | $this->cores = $cores; |
|
100 | 15 | } |
|
101 | |||
102 | /** |
||
103 | * @return int |
||
104 | */ |
||
105 | 13 | public function getBatchLength(): int |
|
108 | } |
||
109 | |||
110 | /** |
||
111 | * @param int $batchLength |
||
112 | */ |
||
113 | 15 | public function setBatchLength(int $batchLength): void |
|
116 | 15 | } |
|
117 | } |
||
118 |