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

StatsSearch   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A search() 0 17 1
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 2018-11-08
6
 */
7
8
namespace app\modules\admin\models\account;
9
10
11
use app\components\visualizations\DateHelper;
12
use app\models\Account;
13
use yii\base\Model;
14
use yii\data\ActiveDataProvider;
15
16
class StatsSearch extends Model
17
{
18
    public function search(Account $model)
19
    {
20
        $query = $model->getAccountStats();
21
22
        $dateRange = DateHelper::getRangeFromUrl();
23
        /**
24
         * @var \Carbon\Carbon $start
25
         * @var \Carbon\Carbon $end
26
         */
27
        list($start, $end) = DateHelper::normalizeRange($dateRange);
0 ignored issues
show
Bug introduced by
It seems like $dateRange can also be of type array; however, parameter $dateRange of app\components\visualiza...elper::normalizeRange() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

27
        list($start, $end) = DateHelper::normalizeRange(/** @scrutinizer ignore-type */ $dateRange);
Loading history...
28
        $query->andWhere(['>=', 'created_at', $start->toDateTimeString()])
29
            ->andWhere(['<=', 'created_at', $end->toDateTimeString()]);
30
31
        return new ActiveDataProvider([
32
            'query' => $query,
33
            'sort' => [
34
                'defaultOrder' => ['created_at' => SORT_DESC],
35
            ],
36
        ]);
37
    }
38
}