Passed
Push — master ( db0af9...5e9f02 )
by Ferry
03:57
created

Hook::indexRender()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 2
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: User
5
 * Date: 2/13/2019
6
 * Time: 5:43 PM
7
 */
8
9
namespace crocodicstudio\crudbooster\types\time;
10
11
use crocodicstudio\crudbooster\types\TypesHook;
12
13
class Hook extends TypesHook
14
{
15
16
    /**
17
     * @param $row
18
     * @param $column DatetimeModel
0 ignored issues
show
Bug introduced by
The type crocodicstudio\crudboost...ypes\time\DatetimeModel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
19
     * @return mixed
20
     */
21
    public function indexRender($row, $column)
22
    {
23
        if($column->getFormat()) {
24
            return date($column->getFormat(), strtotime($row->{$column->getField()}));
25
        }else{
26
            return $row->{$column->getField()};
27
        }
28
    }
29
30
    public function detailRender($row, $column)
31
    {
32
        return $this->indexRender($row, $column);
33
    }
34
35
    public function filterQuery($query, $column, $value)
36
    {
37
        $start = sanitizeXSS($value['start']);
38
        $end = sanitizeXSS($value['end']);
39
        if($start && $end) {
40
            $start = date("H:i:s", strtotime($start));
41
            $end = date("H:i:s", strtotime($end));
42
            $query->whereBetween($column->getFilterColumn(), [$start, $end]);
43
        }
44
        return $query;
45
    }
46
}