Code Duplication    Length = 12-12 lines in 4 locations

src/Type/Scalar/DateTimeType.php 2 locations

@@ 39-50 (lines=12) @@
36
        return $date ? true : false;
37
    }
38
39
    public function serialize($value)
40
    {
41
        $date = null;
42
43
        if (is_string($value)) {
44
            $date = $this->createFromFormat($value);
45
        } elseif ($value instanceof \DateTimeInterface) {
46
            $date = $value;
47
        }
48
49
        return $date ? $date->format($this->format) : null;
50
    }
51
52
    public function parseValue($value)
53
    {
@@ 52-63 (lines=12) @@
49
        return $date ? $date->format($this->format) : null;
50
    }
51
52
    public function parseValue($value)
53
    {
54
        if (is_string($value)) {
55
            $date = $this->createFromFormat($value);
56
        } elseif ($value instanceof \DateTimeInterface) {
57
            $date = $value;
58
        } else {
59
            $date = false;
60
        }
61
62
        return $date ?: null;
63
    }
64
65
    private function createFromFormat($value)
66
    {

src/Type/Scalar/DateTimeTzType.php 2 locations

@@ 32-43 (lines=12) @@
29
        return $date ? true : false;
30
    }
31
32
    public function serialize($value)
33
    {
34
        $date = null;
35
36
        if (is_string($value)) {
37
            $date = $this->createFromFormat($value);
38
        } elseif ($value instanceof \DateTimeInterface) {
39
            $date = $value;
40
        }
41
42
        return $date ? $date->format($this->format) : null;
43
    }
44
45
    public function parseValue($value)
46
    {
@@ 45-56 (lines=12) @@
42
        return $date ? $date->format($this->format) : null;
43
    }
44
45
    public function parseValue($value)
46
    {
47
        if (is_string($value)) {
48
            $date = $this->createFromFormat($value);
49
        } elseif ($value instanceof \DateTimeInterface) {
50
            $date = $value;
51
        } else {
52
            $date = false;
53
        }
54
55
        return $date ?: null;
56
    }
57
58
    private function createFromFormat($value)
59
    {