ElasticsearchIndexConfiguration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
c 0
b 0
f 0
dl 0
loc 29
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A getActivityLogIndexConfig() 0 9 1
A getCurrentDataTrackerIndexConfig() 0 9 1
1
<?php
2
3
namespace Locastic\Loggastic\Bridge\Elasticsearch\Index;
4
5
use Locastic\Loggastic\Bridge\Elasticsearch\Context\ElasticsearchContextInterface;
6
7
final class ElasticsearchIndexConfiguration implements ElasticsearchIndexConfigurationInterface
8
{
9
    public function __construct(private readonly bool $dateDetection, private readonly string $dateFormats, private readonly array $activityLogProperties, private readonly array $currentDataTrackerProperties)
10
    {
11
    }
12
13
    public function getActivityLogIndexConfig(ElasticsearchContextInterface $elasticsearchContext): array
14
    {
15
        return [
16
            'index' => $elasticsearchContext->getActivityLogIndex(),
17
            'body' => [
18
                'mappings' => [
19
                    'date_detection' => $this->dateDetection,
20
                    'dynamic_date_formats' => [$this->dateFormats],
21
                    'properties' => $this->activityLogProperties,
22
                ],
23
            ],
24
        ];
25
    }
26
27
    public function getCurrentDataTrackerIndexConfig(ElasticsearchContextInterface $elasticsearchContext): array
28
    {
29
        return [
30
            'index' => $elasticsearchContext->getCurrentDataTrackerIndex(),
31
            'body' => [
32
                'mappings' => [
33
                    'date_detection' => $this->dateDetection,
34
                    'dynamic_date_formats' => [$this->dateFormats],
35
                    'properties' => $this->currentDataTrackerProperties,
36
                ],
37
            ],
38
        ];
39
    }
40
}
41