Passed
Push — trunk ( ff423b...970276 )
by Christian
13:19 queued 19s
created

ElasticsearchCustomFieldsMappingEvent::getEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Elasticsearch\Event;
4
5
use Shopware\Core\Framework\Context;
6
use Shopware\Core\Framework\Event\ShopwareEvent;
7
use Shopware\Core\Framework\Log\Package;
8
use Shopware\Core\System\CustomField\CustomFieldTypes;
9
10
/**
11
 * @internal
12
 */
13
#[Package('core')]
14
class ElasticsearchCustomFieldsMappingEvent implements ShopwareEvent
15
{
16
    /**
17
     * @param array<string, string> $mapping
18
     */
19
    public function __construct(
20
        private readonly string $entity,
21
        private array $mapping,
22
        private readonly Context $context
23
    ) {
24
    }
25
26
    public function getContext(): Context
27
    {
28
        return $this->context;
29
    }
30
31
    /**
32
     * @param CustomFieldTypes::* $type
0 ignored issues
show
Documentation Bug introduced by
The doc comment $type at position 0 could not be parsed: Unknown type name '$type' at position 0 in $type.
Loading history...
33
     */
34
    public function setMapping(string $field, string $type): void
35
    {
36
        $this->mapping[$field] = $type;
37
    }
38
39
    /**
40
     * @return CustomFieldTypes::*|null
41
     * @return string|null
42
     */
43
    public function getMapping(string $field)
44
    {
45
        return $this->mapping[$field] ?? null;
46
    }
47
48
    public function removeMapping(string $field): void
49
    {
50
        if (isset($this->mapping[$field])) {
51
            unset($this->mapping[$field]);
52
        }
53
    }
54
55
    /**
56
     * @return array<string, string>
57
     */
58
    public function getMappings(): array
59
    {
60
        return $this->mapping;
61
    }
62
63
    public function getEntity(): string
64
    {
65
        return $this->entity;
66
    }
67
}
68