Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ElasticsearchConfiguration | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| getHosts | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Elasticsearch's configuration class |
| 5 | * |
| 6 | * This Source Code Form is subject to the terms of the Mozilla Public License, |
| 7 | * v. 2.0. If a copy of the MPL was not distributed with this file, You can |
| 8 | * obtain one at https://mozilla.org/MPL/2.0/. |
| 9 | * |
| 10 | * @package phpMyFAQ |
| 11 | * @author Thorsten Rinne <thorsten@phpmyfaq.de> |
| 12 | * @copyright 2023-2026 phpMyFAQ Team |
| 13 | * @license https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0 |
| 14 | * @link https://www.phpmyfaq.de |
| 15 | * @since 2023-04-30 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace phpMyFAQ\Configuration; |
| 21 | |
| 22 | readonly class ElasticsearchConfiguration |
| 23 | { |
| 24 | /** @var string[] */ |
| 25 | private array $hosts; |
| 26 | |
| 27 | private string $index; |
| 28 | |
| 29 | public function __construct(string $filename) |
| 30 | { |
| 31 | $PMF_ES = [ |
| 32 | 'hosts' => [], |
| 33 | 'index' => '', |
| 34 | ]; |
| 35 | |
| 36 | include $filename; |
| 37 | |
| 38 | $this->hosts = $PMF_ES['hosts']; |
| 39 | $this->index = $PMF_ES['index']; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * @return string[] |
| 44 | */ |
| 45 | public function getHosts(): array |
| 46 | { |
| 47 | return $this->hosts; |
| 48 | } |
| 49 | |
| 50 | public function getIndex(): string |
| 51 | { |
| 52 | return $this->index; |
| 53 | } |
| 54 | } |