mageekguy\atoum\asserters\mysqlDateTime: lines coverage

100% of 83

OPs

92% of 13

Lines

92% of 12

Branches

80% of 5

Paths
Method OPs OPs % Lines Line % Branches Branches % Paths Path %
mageekguy\atoum\asserters\mysqlDateTime::setWith() 56 100% 11 91% 7 86% 3 67%
mageekguy\atoum\asserters\mysqlDateTime::getValue() 27 100% 2 100% 5 100% 2 100%
#
1
<?php
2

                    
3
namespace mageekguy\atoum\asserters;
4

                    
5
use
6
	mageekguy\atoum\asserters,
7
	mageekguy\atoum\exceptions
8
;
9

                    
10
class mysqlDateTime extends asserters\dateTime
11
{
12
	const mysqlDateTimeFormat = 'Y-m-d H:i:s';
13

                    
14
	public function setWith($value, $checkType = true)91%
15
	{
16
		$phpDate = \dateTime::createFromFormat(self::mysqlDateTimeFormat, $value);
17

                    
18
		if ($phpDate !== false)
19
		{
20
			parent::setWith($phpDate, $checkType);
21
		}
22
		else
23
		{
24
			parent::setWith($value, false);
25

                    
26
			if ($checkType === true)
27
			{
28
				$this->fail($this->_('%s is not in format Y-m-d H:i:s', $this));
29
			}
30
		}
31

                    
32
		return $this;
33
	}
34

                    
35
	public function getValue()100%
36
	{
37
		$value = parent::getValue();
38

                    
39
		return ($value instanceof \dateTime === false ? $value : $value->format(self::mysqlDateTimeFormat));
40
	}
41
}