Passed
Push — master ( 7ba57e...634515 )
by Paweł
03:13
created

BaseDiff   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 7 2
A getModel() 0 3 1
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 2019-01-25
6
 */
7
8
namespace app\components\stats\base;
9
10
11
use app\components\stats\contracts\DiffInterface;
12
use app\components\stats\traits\FromToDateTrait;
13
use app\components\stats\traits\StatsAttributesTrait;
14
use yii\base\BaseObject;
15
use yii\helpers\ArrayHelper;
16
17
abstract class BaseDiff extends BaseObject implements DiffInterface
18
{
19
    use FromToDateTrait, StatsAttributesTrait;
20
21
    protected $data;
22
23
    public function getModel($key): array
24
    {
25
        return ArrayHelper::getValue($this->getData(), $key, []);
26
    }
27
28
    public function getData()
29
    {
30
        if ($this->data === null) {
31
            $this->data = $this->prepareData();
32
        }
33
34
        return $this->data;
35
    }
36
37
    abstract protected function prepareData(): array;
38
}