SQLDataProvider::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
namespace nstdio\yii2notymo\provider;
3
4
use Yii;
5
use yii\base\InvalidConfigException;
6
use yii\db\Query;
7
8
/**
9
 * Class SQLDataProvider
10
 *
11
 * @package nstdio\notymo
12
 * @author  Edgar Asatryan <[email protected]>
13
 */
14
class SQLDataProvider extends DataProvider
15
{
16
    /**
17
     * DataProvider constructor.
18
     *
19
     * @param array $config
20
     *
21
     */
22 6
    public function __construct($config = [])
23
    {
24 6
        parent::__construct($config);
25
26 2
        $this->query = new Query();
27 2
    }
28
29 6
    public function init()
30
    {
31 6
        if (Yii::$app->get('db', false) === null) {
32 1
            throw new InvalidConfigException("You must configure database to use this provider.");
33
        }
34
35 5
        parent::init();
36 2
    }
37
}
38