Passed
Push — master ( 012a39...db05e5 )
by Gordon
03:54 queued 01:45
created

IndexCreator::createIndex()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
rs 9.9332
cc 3
nc 3
nop 1
1
<?php declare(strict_types = 1);
2
3
/**
4
 * Created by PhpStorm.
5
 * User: gordon
6
 * Date: 24/3/2561
7
 * Time: 20:36 น.
8
 */
9
10
namespace Suilven\FreeTextSearch\Base;
11
12
use Suilven\FreeTextSearch\Indexes;
13
14
abstract class IndexCreator implements \Suilven\FreeTextSearch\Interfaces\IndexCreator
15
{
16
    /**
17
     * (Re)create an index of the given name, using the index configuration from YML
18
     *
19
     * @param string $indexName The name of the index
20
     */
21
    public function createIndex(string $indexName): void
22
    {
23
        $indexes = new Indexes();
24
        $indices = $indexes->getIndexes();
25
26
        /** @var \Suilven\FreeTextSearch\Index $indice */
27
        foreach ($indices as $indice) {
28
            $clazz = $indice->getClass();
29
            $instance = \Singleton::getInstance($clazz);
0 ignored issues
show
Unused Code introduced by
The call to Singleton::getInstance() has too many arguments starting with $clazz. ( Ignorable by Annotation )

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

29
            /** @scrutinizer ignore-call */ 
30
            $instance = \Singleton::getInstance($clazz);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
30
            $classes = $instance->getClassAncestry();
31
            \error_log(\print_r($classes, true));
32
33
            foreach ($classes as $indiceClass) {
34
                    $fields = $indice->getFields();
35
                    \error_log(\print_r($fields, 1));
36
            }
37
        }
38
    }
39
}
40