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

DateTimeRangePicker   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 26
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 3 1
A __construct() 0 7 1
A getFilterAction() 0 3 1
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
\kalanis\kw_table\form_nette_lte\Controls\DateTimeRange::register();
11
12
13
/**
14
 * Class Listing\Connector\Form\Field\Nette\DateTimePicker
15
 * @package kalanis\kw_table\form_nette_lte\Controls
16
 */
17
class DateTimeRangePicker extends Fields\AField
18
{
19
    /** @var \DateTime|null */
20
    protected $startTime;
21
    /** @var \DateTime|null */
22
    protected $endTime;
23
    /** @var string|null */
24
    protected $searchFormat;
25
26
    public function __construct(?\DateTime $startTime = null, ?\DateTime $endTime = null, ?string $searchFormat = null, array $attributes = [])
27
    {
28
        $this->startTime = $startTime;
29
        $this->endTime = $endTime;
30
        $this->searchFormat = $searchFormat;
31
32
        parent::__construct($attributes);
33
    }
34
35
    public function getFilterAction(): string
36
    {
37
        return IFilterFactory::ACTION_RANGE;
38
    }
39
40
    public function add(): void
41
    {
42
        $this->form->addAdminLteDateTimeRange($this->alias, null, null, $this->searchFormat, $this->startTime, $this->endTime);
43
    }
44
}
45