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

DateHelper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
c 1
b 0
f 0
dl 0
loc 28
rs 10

2 Methods

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