/** * Converts a value from its database representation to its PHP representation * * @param mixed $value The value to convert * @param AbstractPlatform $platform The currently used database platform * * @return mixed * * @throws ConversionException When the conversion fails */ public function convertToPHPValue($value, AbstractPlatform $platform) { if (empty($value)) { return null; } if ($value instanceof Date) { return $value; } try { $date = Date::fromString($value); } catch (Exception $exception) { throw ConversionException::conversionFailed($value, static::TYPE_NAME); } return $date; }
/** * @expectedException \AssertionError */ public function test_that_compare_to_throws_exception_for_invalid_argument() { $date = Date::create(2015, 6, 20); $date->compareTo('2015-06-20'); }
/** * Retrieves the day * * @return int */ public function day() { return $this->date->day(); }
public function test_that_with_date_returns_expected_instance() { $dateTime = DateTime::now(); $dateTime = $dateTime->withDate(Date::create(2016, 1, 1)); $this->assertSame('2016-01-01', $dateTime->date()->toString()); }
/** * @expectedException Novuso\System\Exception\DomainException */ public function test_that_from_string_throws_exception_for_invalid_format() { Date::fromString('06-20-2015'); }