AbstractDataProvider::getRecordClassName()
last analyzed

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 *
4
 * @author Mihkel Viilveer <[email protected]>
5
 * @date 22.08.2014
6
 */
7
8
namespace opus\elastic\spooler;
9
10
use yii\base\BaseObject;
11
12
/**
13
 * Interface DataProviderAbstract
14
 *
15
 * @package opus\elastic
16
 */
17
abstract class AbstractDataProvider extends BaseObject
18
{
19
    /**
20
     * Languages
21
     * @var array
22
     */
23
    public $languages = [];
24
25
    /**
26
     * @var string[][] Elastic index mapping
27
     */
28
    private $mapping = [];
29
30
    /**
31
     * Provides data to spool into elastic
32
     *
33
     * @return array
34
     */
35
    abstract function getData();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
36
37
    /**
38
     * Gives ES type name where the data should be inserted to
39
     * @return string
40
     */
41
    abstract function getTypeName();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
42
43
    /**
44
     * Gives ES index name where the data should be inserted to
45
     * @return string
46
     */
47
    abstract function getIndexName();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
48
49
    /**
50
     * Returns ActiveRecord class name
51
     * @return string
52
     */
53
    abstract function getRecordClassName();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
54
55
    /**
56
     * Returns ActiveRecord table name
57
     * @return string
58
     */
59
    abstract function getRecordClassTableName();
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
60
61
    /**
62
     * @return array
63
     */
64
    public function getMapping()
65
    {
66
        if (empty($this->mapping)) {
67
            /** @var AbstractMappingProvider $mappingProvider */
68
            $mappingProvider = \Yii::createObject('opus\elastic\spooler\AbstractMappingProvider');
69
            $attributes = $mappingProvider->build($this->languages);
70
71
            $this->mapping = [
0 ignored issues
show
Documentation Bug introduced by
It seems like array($this->getTypeName() => $attributes) of type array<string,array> is incompatible with the declared type array<integer,array<integer,string>> of property $mapping.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
72
                $this->getTypeName() => $attributes
73
            ];
74
        }
75
        return $this->mapping;
76
77
    }
78
79
    /**
80
     * Callback to be used to init dependant data
81
     * @return mixed
82
     */
83
    abstract public function initializeDependentData();
84
}
85