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

StuTime   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 84.62%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 24
ccs 11
cts 13
cp 0.8462
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A time() 0 3 1
A transformToStuDateTime() 0 6 1
A transformToStuDate() 0 6 1
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