Passed
Pull Request — master (#3)
by Gordon
01:51
created

Indexer::setDatabaseName()   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 1
dl 0
loc 3
rs 10
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: gordon
5
 * Date: 24/3/2561
6
 * Time: 21:14 น.
7
 */
8
9
namespace Suilven\ManticoreSearch\Service;
10
11
use SilverStripe\Core\Config\Config;
12
use Suilven\FreeTextSearch\Indexes;
13
use Suilven\ManticoreSearch\Helper\ReconfigureIndexesHelper;
14
15
class Indexer
16
{
17
    /**
18
     * @var null|Indexes indexes in current context
19
     */
20
    private $indexes = null;
21
22
23
    /**
24
     * Indexer constructor.
25
     * @param Indexes $indexes indexes in context
26
     */
27
    public function __construct($indexes)
28
    {
29
        $this->indexes = $indexes;
30
31
        $config = Config::inst()->get('Suilven\FreeTextSearch\Indexes', 'indexes') ;
0 ignored issues
show
Unused Code introduced by
The assignment to $config is dead and can be removed.
Loading history...
32
    }
33
34
35
    public function reconfigureIndexes()
36
    {
37
        $helper = new ReconfigureIndexesHelper();
38
        $helper->reconfigureIndexes($this->indexes);
0 ignored issues
show
Bug introduced by
It seems like $this->indexes can also be of type Suilven\FreeTextSearch\Indexes; however, parameter $indexes of Suilven\ManticoreSearch\...r::reconfigureIndexes() does only seem to accept Suilven\FreeTextSearch\Index[], maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        $helper->reconfigureIndexes(/** @scrutinizer ignore-type */ $this->indexes);
Loading history...
39
    }
40
}
41