Completed
Push — master ( ec1997...dcb85b )
by Edgar
10:53
created

SQLDataProvider::addSelectIfNotNull()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 8
cts 8
cp 1
rs 9.6666
c 0
b 0
f 0
nc 2
cc 2
eloc 6
nop 1
crap 2
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
    public function __construct($config = [])
23
    {
24
        parent::__construct($config);
25
26
        $this->query = new Query();
27 6
    }
28
29 6
    public function init()
30
    {
31 2
        if (Yii::$app->get('db', false) === null) {
32 2
            throw new InvalidConfigException("You must configure database to use this provider.");
33
        }
34 6
35
        parent::init();
36 6
    }
37
}
38