StatsSearch   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 19
rs 10
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-11
6
 */
7
8
namespace app\modules\admin\models\tag;
9
10
11
use app\components\visualizations\DateHelper;
12
use app\models\Tag;
13
use yii\base\Model;
14
use yii\data\ActiveDataProvider;
15
16
class StatsSearch extends Model
17
{
18
    public function search(Tag $model)
19
    {
20
        $query = $model->getTagStats();
21
22
        $dateRange = DateHelper::getRangeFromUrl();
23
        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

23
        list($start, $end) = DateHelper::normalizeRange(/** @scrutinizer ignore-type */ $dateRange);
Loading history...
24
        /**
25
         * @var \Carbon\Carbon $start
26
         * @var \Carbon\Carbon $end
27
         */
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
}