Passed
Push — 4-cactus ( 5bd7f8...3cd9c3 )
by Alberto
03:00
created

DateType::marshal()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * BEdita, API-first content management framework
4
 * Copyright 2018 ChannelWeb Srl, Chialab Srl
5
 *
6
 * This file is part of BEdita: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published
8
 * by the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
12
 */
13
14
namespace BEdita\Core\Database\Type;
15
16
use Cake\Database\Type\DateType as CakeDateType;
17
use DateTime;
18
19
/**
20
 * Custom DateType class with simplified marshal
21
 */
22
class DateType extends CakeDateType
23
{
24
    /**
25
     * {@inheritDoc}
26
     */
27
    public function marshal($value)
28
    {
29
        $date = DateTimeType::marshalDateTime($value, $this->getDateTimeClassName());
30
        if ($date instanceof DateTime) {
31
            $date->setTime(0, 0, 0);
32
        }
33
34
        return $date;
35
    }
36
}
37