Passed
Push — master ( 92620c...1c7b90 )
by Petr
16:04 queued 07:51
created

DateTimePicker::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php
2
3
namespace kalanis\kw_table\form_nette_lte\Fields;
4
5
6
use kalanis\kw_connect\core\Interfaces\IFilterFactory;
7
use kalanis\kw_table\form_nette\Fields;
8
9
10
/**
11
 * Class DateTimePicker
12
 * @package kalanis\kw_table\form_nette_lte\Controls
13
 */
14
class DateTimePicker extends Fields\AField
15
{
16
    /** @var \DateTime|null */
17
    protected $startTime;
18
    /** @var \DateTime|null */
19
    protected $endTime;
20
    /** @var string|null */
21
    protected $searchFormat;
22
23
    public function __construct(?\DateTime $startTime = null, ?\DateTime $endTime = null, ?string $searchFormat = null, array $attributes = [])
24
    {
25
        $this->startTime = $startTime;
26
        $this->endTime = $endTime;
27
        $this->searchFormat = $searchFormat;
28
29
        parent::__construct($attributes);
30
    }
31
32
    public function getFilterAction(): string
33
    {
34
        return IFilterFactory::ACTION_RANGE;
35
    }
36
37
    public function add(): void
38
    {
39
        $this->form->addAdminLteDateTimeRange($this->alias, null, null, $this->searchFormat, $this->startTime, $this->endTime);
40
    }
41
}
42