Esempio n. 1
0
 /**
  * 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;
 }
Esempio n. 2
0
 /**
  * @expectedException \AssertionError
  */
 public function test_that_compare_to_throws_exception_for_invalid_argument()
 {
     $date = Date::create(2015, 6, 20);
     $date->compareTo('2015-06-20');
 }
Esempio n. 3
0
 /**
  * Retrieves the day
  *
  * @return int
  */
 public function day()
 {
     return $this->date->day();
 }
Esempio n. 4
0
 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());
 }
Esempio n. 5
0
 /**
  * @expectedException Novuso\System\Exception\DomainException
  */
 public function test_that_from_string_throws_exception_for_invalid_format()
 {
     Date::fromString('06-20-2015');
 }