DateTimeRangePickerButton::add()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
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\AField;
9
10
11
\kalanis\kw_table\form_nette_lte\Controls\DateTimeRangeButton::register();
12
13
14
/**
15
 * Class DateTimeRangePickerButton
16
 * @package kalanis\kw_table\form_nette_lte\Fields
17
 */
18
class DateTimeRangePickerButton extends AField
19
{
20
    protected ?string $searchFormat = null;
21
    protected ?dt $startTime;
22
    protected ?dt $endTime;
23
24
    public function __construct(?string $searchFormat = null, ?dt $startTime = null, ?dt $endTime = null, array $attributes = [])
25
    {
26
        $this->searchFormat = $searchFormat;
27
        $this->startTime = $startTime;
28
        $this->endTime = $endTime;
29
30
        parent::__construct($attributes);
31
    }
32
33
    public function getFilterAction(): string
34
    {
35
        return IFilterFactory::ACTION_RANGE;
36
    }
37
38
    public function add(): void
39
    {
40
        $this->form->addDateTimeRangeButton($this->alias, null, null, $this->searchFormat, $this->startTime, $this->endTime);
41
    }
42
}
43