Passed
Push — feature/initial-implementation ( 70fbec...2d1ee1 )
by Fike
02:35
created

Entity::getMapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AmaTeam\ElasticSearch\Entity;
6
7
use AmaTeam\ElasticSearch\API\Entity\EntityInterface;
8
use AmaTeam\ElasticSearch\API\Entity\Indexing\Indexing;
9
use AmaTeam\ElasticSearch\API\Entity\Indexing\IndexingInterface;
10
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMapping;
11
use AmaTeam\ElasticSearch\API\Entity\Mapping\ClassMappingInterface;
12
13
class Entity implements EntityInterface
14
{
15
    /**
16
     * @var string
17
     */
18
    private $name;
19
    /**
20
     * @var string|null
21
     */
22
    private $parentName;
23
    /**
24
     * @var bool
25
     */
26
    private $rootLevelDocument = false;
27
    /**
28
     * @var ClassMappingInterface
29
     */
30
    private $mapping;
31
    /**
32
     * @var IndexingInterface
33
     */
34
    private $indexing;
35
36
    public function __construct(string $name = null)
37
    {
38
        $this->name = $name;
39
        $this->mapping = new ClassMapping($name);
40
        $this->indexing = new Indexing();
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getName(): string
47
    {
48
        return $this->name;
49
    }
50
51
    /**
52
     * @param string $name
53
     * @return $this
54
     */
55
    public function setName(string $name)
56
    {
57
        $this->name = $name;
58
        return $this;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getParentName(): ?string
65
    {
66
        return $this->parentName;
67
    }
68
69
    /**
70
     * @param string $parentName
71
     * @return $this
72
     */
73
    public function setParentName(string $parentName)
74
    {
75
        $this->parentName = $parentName;
76
        return $this;
77
    }
78
79
    /**
80
     * @return bool
81
     */
82
    public function isRootLevelDocument(): bool
83
    {
84
        return $this->rootLevelDocument;
85
    }
86
87
    /**
88
     * @param bool $rootLevelDocument
89
     * @return $this
90
     */
91
    public function setRootLevelDocument(bool $rootLevelDocument)
92
    {
93
        $this->rootLevelDocument = $rootLevelDocument;
94
        return $this;
95
    }
96
97
    /**
98
     * @return ClassMappingInterface
99
     */
100
    public function getMapping(): ?ClassMappingInterface
101
    {
102
        return $this->mapping;
103
    }
104
105
    /**
106
     * @param ClassMappingInterface $mapping
107
     * @return $this
108
     */
109
    public function setMapping(ClassMappingInterface $mapping)
110
    {
111
        $this->mapping = $mapping;
112
        return $this;
113
    }
114
115
    /**
116
     * @return IndexingInterface
117
     */
118
    public function getIndexing(): ?IndexingInterface
119
    {
120
        return $this->indexing;
121
    }
122
123
    /**
124
     * @param IndexingInterface $indexing
125
     * @return $this
126
     */
127
    public function setIndexing(IndexingInterface $indexing)
128
    {
129
        $this->indexing = $indexing;
130
        return $this;
131
    }
132
}
133