Passed
Pull Request — developer (#16984)
by Arkadiusz
29:54
created

DatetimeField::operatorCustom()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace App\Conditions\RecordFields;
4
5
/**
6
 * Datetime field condition record field class.
7
 *
8
 * @package UIType
9
 *
10
 * @copyright YetiForce S.A.
11
 * @license   YetiForce Public License 5.0 (licenses/LicenseEN.txt or yetiforce.com)
12
 * @author    Mariusz Krzaczkowski <[email protected]>
13
 */
14
class DatetimeField extends DateField
15
{
16
	/**
17
	 * Between operator.
18
	 *
19
	 * @return array
20
	 */
21
	public function operatorBw()
22
	{
23
		[$startDate, $endDate] = explode(',', $this->value);
24
		$dateValue = date('Y-m-d H:i:s', strtotime($this->getValue()));
25
		return ($dateValue >= date('Y-m-d H:i:s', strtotime($startDate))) && ($dateValue <= date('Y-m-d H:i:s', strtotime($endDate)));
0 ignored issues
show
Bug Best Practice introduced by
The expression return $dateValue >= dat...', strtotime($endDate)) returns the type boolean which is incompatible with the documented return type array.
Loading history...
26
	}
27
28
	/**
29
	 * Smaller operator.
30
	 *
31
	 * @return bool
32
	 */
33
	public function operatorSmaller()
34
	{
35
		return strtotime($this->getValue()) < strtotime('now');
36
	}
37
38
	/**
39
	 * Greater operator.
40
	 *
41
	 * @return bool
42
	 */
43
	public function operatorGreater()
44
	{
45
		return strtotime($this->getValue()) > strtotime('now');
46
	}
47
}
48