| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Date\DateInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class DateIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param DateInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof DateInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|DateInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return DateInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'DateInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\DateTime\DateTimeInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class DateTimeIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param DateTimeInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof DateTimeInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|DateTimeInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return DateTimeInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'DateTimeInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\IPv4\IPv4Interval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class IPv4IntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param IPv4Interval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof IPv4Interval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|IPv4Interval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return IPv4Interval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'IPv4Interval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Month\MonthInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class MonthIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param MonthInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof MonthInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|MonthInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return MonthInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'MonthInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Number\NumberInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class NumberIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param NumberInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof NumberInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|NumberInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return NumberInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'NumberInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Time\TimeInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class TimeIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param TimeInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof TimeInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|TimeInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return TimeInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'TimeInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Week\WeekInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class WeekIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param WeekInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof WeekInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|WeekInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return WeekInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'WeekInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||
| @@ 19-60 (lines=42) @@ | ||
| 16 | use GpsLab\Component\Interval\Year\YearInterval; |
|
| 17 | use GpsLab\Component\Interval\Exception\InvalidIntervalFormatException; |
|
| 18 | ||
| 19 | class YearIntervalType extends TextType |
|
| 20 | { |
|
| 21 | /** |
|
| 22 | * @param YearInterval|null $value |
|
| 23 | * @param AbstractPlatform $platform |
|
| 24 | * |
|
| 25 | * @return null|string |
|
| 26 | */ |
|
| 27 | public function convertToDatabaseValue($value, AbstractPlatform $platform) |
|
| 28 | { |
|
| 29 | return $value instanceof YearInterval ? (string)$value : null; |
|
| 30 | } |
|
| 31 | ||
| 32 | /** |
|
| 33 | * @throws ConversionException |
|
| 34 | * |
|
| 35 | * @param mixed $value |
|
| 36 | * @param AbstractPlatform $platform |
|
| 37 | * |
|
| 38 | * @return null|YearInterval |
|
| 39 | */ |
|
| 40 | public function convertToPHPValue($value, AbstractPlatform $platform) |
|
| 41 | { |
|
| 42 | if ($value === null) { |
|
| 43 | return null; |
|
| 44 | } |
|
| 45 | ||
| 46 | try { |
|
| 47 | return YearInterval::fromString($value); |
|
| 48 | } catch (InvalidIntervalFormatException $e) { |
|
| 49 | throw ConversionException::conversionFailed($value, $this->getName()); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return string |
|
| 55 | */ |
|
| 56 | public function getName() |
|
| 57 | { |
|
| 58 | return 'YearInterval'; |
|
| 59 | } |
|
| 60 | } |
|
| 61 | ||