Passed
Pull Request — master (#1887)
by Janko
53:41
created

StuTime::transformToStuDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Stu\Module\Control;
4
5
/**
6
 * This class adds the possibility to inject a timestamp generator
7
 */
8
class StuTime
9
{
10
    public const STU_YEARS_IN_FUTURE_OFFSET = 370;
11
12
    public function time(): int
13
    {
14
        return time();
15
    }
16
17 2
    public function transformToStuDate(int $unixTimestamp): string
18
    {
19 2
        return sprintf(
20 2
            '%s%s',
21 2
            date('d.m.', $unixTimestamp),
22 2
            (int)date("Y", $unixTimestamp) + StuTime::STU_YEARS_IN_FUTURE_OFFSET,
23 2
        );
24
    }
25
26 1
    public function transformToStuDateTime(int $unixTimestamp): string
27
    {
28 1
        return sprintf(
29 1
            '%s %s',
30 1
            $this->transformToStuDate($unixTimestamp),
31 1
            date("H:i", $unixTimestamp)
32 1
        );
33
    }
34
}
35