Completed
Push — master ( 161974...89e423 )
by WEBEWEB
03:36
created

DateTimeRenderer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A renderDateTime() 0 6 2
1
<?php
2
3
/*
4
 * This file is part of the core-bundle package.
5
 *
6
 * (c) 2019 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Bundle\CoreBundle\Renderer;
13
14
use DateTime;
15
16
/**
17
 * Date/time renderer.
18
 *
19
 * @author webeweb <https://github.com/webeweb/>
20
 * @package WBW\Bundle\CoreBundle\Renderer
21
 */
22
class DateTimeRenderer {
23
24
    /**
25
     * Date/time format.
26
     *
27
     * @var string
28
     */
29
    const DATETIME_FORMAT = "Y-m-d H:i";
30
31
    /**
32
     * Render a date/time.
33
     *
34
     * @param DateTime $dateTime The date/time.
35
     * @param string $format The format.
36
     * @return string Returns the rendered date/time.
37
     */
38
    public static function renderDateTime(DateTime $dateTime = null, $format = self::DATETIME_FORMAT) {
39
        if (null === $dateTime) {
40
            return "";
41
        }
42
        return $dateTime->format($format);
43
    }
44
45
}
46