Code Duplication    Length = 35-35 lines in 2 locations

src/Types/DateTimeType.php 1 location

@@ 26-60 (lines=35) @@
23
/**
24
 * @package Limoncello\Flute
25
 */
26
class DateTimeType extends BaseDateTimeType
27
{
28
    use TypeTrait;
29
30
    /** Type name */
31
    const NAME = 'limoncelloDateTime';
32
33
    /**
34
     * @inheritdoc
35
     *
36
     * @SuppressWarnings(PHPMD.StaticAccess)
37
     */
38
    public function convertToPHPValue($value, AbstractPlatform $platform)
39
    {
40
        $result = null;
41
42
        if ($value !== null && ($dateTimeOrNull = parent::convertToPHPValue($value, $platform)) !== null) {
43
            assert($dateTimeOrNull instanceof DateTimeInterface);
44
            $result = $this->convertToJsonApiDateTime($dateTimeOrNull);
45
        }
46
47
        return $result;
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
54
    {
55
        return parent::convertToDatabaseValue(
56
            $this->convertToDateTimeFromString($value, $platform->getDateTimeFormatString(), static::NAME),
57
            $platform
58
        );
59
    }
60
}
61

src/Types/DateType.php 1 location

@@ 26-60 (lines=35) @@
23
/**
24
 * @package Limoncello\Flute
25
 */
26
class DateType extends BaseDateType
27
{
28
    use TypeTrait;
29
30
    /** Type name */
31
    const NAME = 'limoncelloDate';
32
33
    /**
34
     * @inheritdoc
35
     *
36
     * @SuppressWarnings(PHPMD.StaticAccess)
37
     */
38
    public function convertToPHPValue($value, AbstractPlatform $platform)
39
    {
40
        $result = null;
41
42
        if ($value !== null && ($dateOrNull = parent::convertToPHPValue($value, $platform)) !== null) {
43
            assert($dateOrNull instanceof DateTimeInterface);
44
            $result = $this->convertToJsonApiDateTime($dateOrNull);
45
        }
46
47
        return $result;
48
    }
49
50
    /**
51
     * @inheritdoc
52
     */
53
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
54
    {
55
        return parent::convertToDatabaseValue(
56
            $this->convertToDateTimeFromString($value, $platform->getDateTimeFormatString(), static::NAME),
57
            $platform
58
        );
59
    }
60
}
61