Completed
Push — master ( ceee37...536973 )
by Enea
02:33
created

Format::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by enea dhack - 23/11/2019 18:35.
4
 */
5
6
namespace Vaened\Searcher\Dates;
7
8
use Carbon\Carbon;
9
use Vaened\Enum\Enum;
10
11
/**
12
 * Class Format
13
 *
14
 * @package Components\Dates
15
 * @author enea dhack <[email protected]>
16
 *
17
 * @method static Format YMD()
18
 * @method static Format YMD_HIS()
19
 * @method static Format YMD_HIA()
20
 * @method static Format DMY()
21
 * @method static Format DMY_HIS()
22
 * @method static Format DMY_HIA()
23
 * @method static Format HIS()
24
 * @method static Format HIA()
25
 */
26
class Format extends Enum
27
{
28
    public const YMD = 'Y-m-d';
29
30
    public const YMD_HIS = 'Y-m-d H:i:s';
31
32
    public const YMD_HIA = 'Y-m-d H:i A';
33
34
    public const DMY = 'd-m-Y';
35
36
    public const DMY_HIS = 'd-m-Y H:i:s';
37
38
    public const DMY_HIA = 'd-m-Y H:i A';
39
40
    public const HIS = 'H:i:s';
41
42
    public const HIA = 'H:i A';
43
44
    public function apply(Carbon $date): string
45
    {
46
        return $date->format($this->value());
47
    }
48
}
49