DateTimeRangePickerButton   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 10
c 1
b 0
f 0
dl 0
loc 23
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A getFilterAction() 0 3 1
A __construct() 0 7 1
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