Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created

DateRange::getComponentDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * @link http://www.newicon.net/neon
4
 * @copyright Copyright (c) 21/09/2016 Newicon Ltd
5
 * @license http://www.newicon.net/neon/license/
6
 */
7
8
namespace neon\core\form\fields\el;
9
10
use neon\core\grid\query\IQuery;
11
use neon\core\form\fields\Field;
12
use neon\core\form\fields\el\assets\ElAsset;
13
use neon\core\helpers\Html;
14
use neon\core\helpers\Arr;
15
16
class DateRange extends DateTimeRange
17
{
18
	public $type = 'daterange';
19
20
	/**
21
	 * @inheritdoc
22
	 */
23
	public function getProperties()
24
	{
25
		return array_merge(parent::getProperties(), ['type', 'format']);
26
	}
27
28
	/**
29
	 * @inheritdoc
30
	 */
31
	public function getValue()
32
	{
33
		$value = parent::getValue();
34
		if (is_array($value))
0 ignored issues
show
introduced by
The condition is_array($value) is always true.
Loading history...
35
			return $value;
36
		return ['from' => '', 'to' => ''];
37
	}
38
39
	/**
40
	 * Get the picker format
41
	 * @return string
42
	 */
43
	public function getFormat()
44
	{
45
		return neon()->formatter->dateFormat;
46
	}
47
48
	/**
49
	 * @inheritdoc
50
	 */
51
	public function registerScripts($view)
52
	{
53
		ElAsset::register($view);
54
	}
55
56
	/**
57
	 * @inheritdoc
58
	 */
59
	public function getComponentDetails()
60
	{
61
		return [
62
			'label' => 'DateRange', 'group' => 'Form Only', 'icon' => 'fa fa-calendar-o', 'order' => 910,
63
		];
64
	}
65
}