Index   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 25
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOriginalName() 0 4 1
A overrideName() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\ElasticaBundle\Elastica;
13
14
use Elastica\Index as BaseIndex;
15
16
/**
17
 * Overridden Elastica Index class that provides dynamic index name changes.
18
 *
19
 * @author Konstantin Tjuterev <[email protected]>
20
 */
21
class Index extends BaseIndex
22
{
23
    private $originalName;
24
25
    /**
26
     * Returns the original name of the index if the index has been renamed for reindexing
27
     * or realiasing purposes.
28
     */
29
    public function getOriginalName(): string
30
    {
31
        return $this->originalName ?? $this->_name;
32
    }
33
34
    /**
35
     * Reassign index name.
36
     *
37
     * While it's technically a regular setter for name property, it's specifically named overrideName, but not setName
38
     * since it's used for a very specific case and normally should not be used
39
     */
40
    public function overrideName(string $name): void
41
    {
42
        $this->originalName = $this->_name;
43
        $this->_name = $name;
44
    }
45
}
46