コード例 #1
0
ファイル: TimeType.php プロジェクト: novuso/common-bundle
 /**
  * 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 Time) {
         return $value;
     }
     try {
         $time = Time::fromString($value);
     } catch (Exception $exception) {
         throw ConversionException::conversionFailed($value, static::TYPE_NAME);
     }
     return $time;
 }
コード例 #2
0
ファイル: TimeTest.php プロジェクト: novuso/common
 /**
  * @expectedException \AssertionError
  */
 public function test_that_compare_to_throws_exception_for_invalid_argument()
 {
     $time = Time::create(16, 30, 6);
     $time->compareTo('16:30:06');
 }
コード例 #3
0
ファイル: DateTime.php プロジェクト: novuso/common-l
 /**
  * Retrieves the microsecond
  *
  * @return int
  */
 public function micro()
 {
     return $this->time->micro();
 }
コード例 #4
0
ファイル: DateTimeTest.php プロジェクト: novuso/common
 public function test_that_with_time_returns_expected_instance()
 {
     $dateTime = DateTime::now();
     $dateTime = $dateTime->withTime(Time::create(12, 0, 0));
     $this->assertSame('12:00:00', $dateTime->time()->toString());
 }
コード例 #5
0
ファイル: DateTime.php プロジェクト: novuso/common
 /**
  * Retrieves the second
  *
  * @return int
  */
 public function second() : int
 {
     return $this->time->second();
 }
コード例 #6
0
ファイル: TimeTest.php プロジェクト: novuso/common-l
 /**
  * @expectedException Novuso\System\Exception\DomainException
  */
 public function test_that_from_string_throws_exception_for_invalid_format()
 {
     Time::fromString('16:30:06');
 }