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

AbstractTool::getDbc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
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