Passed
Push — master ( d388f3...dbf17a )
by Peter
02:41
created

DateHelper::format()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Admin\Helper;
6
7
use AbterPhp\Admin\Constant\Env;
8
use AbterPhp\Framework\Helper\DateHelper as FrameworkDateHelper;
9
use Opulence\Environments\Environment;
10
11
class DateHelper extends FrameworkDateHelper
12
{
13
    /**
14
     * @param \DateTime|null $dateTime
15
     *
16
     * @return string
17
     */
18
    public static function format(?\DateTime $dateTime): string
19
    {
20
        if (!$dateTime) {
21
            return '';
22
        }
23
24
        return $dateTime->format(Environment::getVar(Env::ADMIN_DATE_FORMAT));
25
    }
26
27
    /**
28
     * @param \DateTime|null $dateTime
29
     *
30
     * @return string
31
     */
32
    public static function formatDateTime(?\DateTime $dateTime): string
33
    {
34
        if (!$dateTime) {
35
            return '';
36
        }
37
38
        return $dateTime->format(Environment::getVar(Env::ADMIN_DATETIME_FORMAT));
39
    }
40
}
41