Completed
Push — master ( 834807...71556e )
by Andrii
01:51
created

AbstractTool   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 34
ccs 0
cts 19
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A getDi() 0 4 1
A getDbc() 0 4 1
1
<?php
2
/**
3
 * HiAPI Yii2 base project for building API
4
 *
5
 * @link      https://github.com/hiqdev/hiapi
6
 * @package   hiapi
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiapi\components;
12
13
use g;
14
use Yii;
15
16
abstract class AbstractTool extends \yii\base\Component
17
{
18
    protected $base;
19
20
    /**
21
     * @var array tool configuration
22
     */
23
    protected $data;
24
25
    public function __construct($base, $data)
26
    {
27
        $this->base = $base;
28
        $this->data = $data;
29
30
        /// XXX WTF? $base->di becomes null after passing as argument
31
        /// TODO fix!
32
        if ($this->base->di === null) {
33
            $this->base->di = Yii::$container;
34
        }
35
        if ($this->base->dbc === null) {
36
            $this->base->dbc = g::dbc();
37
        }
38
    }
39
40
    public function getDi()
41
    {
42
        return $this->base->di;
43
    }
44
45
    public function getDbc()
46
    {
47
        return $this->base->dbc;
48
    }
49
}
50