T3Datetime   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A translate() 0 3 2
A reverse() 0 3 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2014-2025
7
 * @package MShop
8
 * @subpackage Common
9
 */
10
11
12
namespace Aimeos\Base\Criteria\Plugin;
13
14
15
/**
16
 * Criteria plugin for TYPO3 date/time values.
17
 *
18
 * @package MW
19
 * @subpackage Common
20
 */
21
class T3Datetime implements \Aimeos\Base\Criteria\Plugin\Iface
22
{
23
	/**
24
	 * Translates ISO dates into seconds relative to the epoch.
25
	 *
26
	 * @param string $value ISO date string (YYYY-MM-DD HH:mm:ss)
27
	 * @param mixed $type Expected value type
28
	 * @return integer Seconds relative to the epoch
29
	 */
30
	public function translate( $value, $type = null )
31
	{
32
		return ( $value != null ? strtotime( $value ) : 0 );
33
	}
34
35
36
	/**
37
	 * Reverses the translation from seconds relative to the epoch to the ISO date string (YYYY-MM-DD HH:mm:ss).
38
	 *
39
	 * @param integer $value Seconds relative to the epoch
40
	 * @param mixed $type Expected value type
41
	 * @return string ISO date string (YYYY-MM-DD HH:mm:ss)
42
	 */
43
	public function reverse( $value, $type = null )
44
	{
45
		return ( $value != 0 ? date( 'Y-m-d H:i:s', $value ) : null );
46
	}
47
}
48