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

DateType   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 13
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A marshal() 0 8 2
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