DateTimePicker::__construct()   A
last analyzed

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 DateTime as dt;
7
use kalanis\kw_connect\core\Interfaces\IFilterFactory;
8
use kalanis\kw_table\form_nette\Fields;
9
10
11
/**
12
 * Class DateTimePicker
13
 * @package kalanis\kw_table\form_nette_lte\Controls
14
 */
15
class DateTimePicker extends Fields\AField
16
{
17
    protected ?dt $startTime;
18
    protected ?dt $endTime;
19
    protected ?string $searchFormat;
20
21
    public function __construct(?dt $startTime = null, ?dt $endTime = null, ?string $searchFormat = null, array $attributes = [])
22
    {
23
        $this->startTime = $startTime;
24
        $this->endTime = $endTime;
25
        $this->searchFormat = $searchFormat;
26
27
        parent::__construct($attributes);
28
    }
29
30
    public function getFilterAction(): string
31
    {
32
        return IFilterFactory::ACTION_RANGE;
33
    }
34
35
    public function add(): void
36
    {
37
        $this->form->addAdminLteDateTimeRange($this->alias, null, null, $this->searchFormat, $this->startTime, $this->endTime);
38
    }
39
}
40