Passed
Push — master ( 9ca41e...5ddaee )
by Adrien
13:19
created

Utility::printFiles()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 2
dl 0
loc 12
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application;
6
7
use DateTimeImmutable;
8
9
abstract class Utility
10
{
11
    /**
12
     * @var DateTimeImmutable
13
     */
14
    private static $now;
15
16
    /**
17
     * Returns now, always same value for a single PHP execution
18
     *
19
     * @return DateTimeImmutable
20
     */
21
    public static function getNow(): DateTimeImmutable
22
    {
23
        if (!self::$now) {
24
            self::$now = new DateTimeImmutable();
25
        }
26
27
        return self::$now;
28
    }
29
30
    /**
31
     * Returns the short class name of any object, eg: Application\Model\Calendar => Calendar
32
     *
33
     * @param object $object
34
     *
35
     * @return string
36
     */
37
    public static function getShortClassName($object): string
38
    {
39
        $reflect = new \ReflectionClass($object);
40
41
        return $reflect->getShortName();
42
    }
43
}
44