Completed
Push — 2.1 ( 667ca6...384358 )
by Paweł
17s queued 11s
created

DateTime::resetCurrentDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Common Component.
7
 *
8
 * Copyright 2019 Sourcefabric z.u. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2019 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Component\Common\Model;
18
19
final class DateTime
20
{
21
    private static $dateTime;
22
23
    public static function getCurrentDateTime(): \DateTimeInterface
24
    {
25
        if (null !== static::$dateTime) {
0 ignored issues
show
Comprehensibility introduced by
Since SWP\Component\Common\Model\DateTime is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
26
            return static::$dateTime;
0 ignored issues
show
Comprehensibility introduced by
Since SWP\Component\Common\Model\DateTime is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
27
        }
28
29
        return new \DateTime();
30
    }
31
32
    public static function setCurrentDateTime(\DateTimeInterface $dateTime): void
33
    {
34
        static::$dateTime = $dateTime;
0 ignored issues
show
Comprehensibility introduced by
Since SWP\Component\Common\Model\DateTime is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
35
    }
36
37
    public static function resetCurrentDateTime(): void
38
    {
39
        static::$dateTime = null;
0 ignored issues
show
Comprehensibility introduced by
Since SWP\Component\Common\Model\DateTime is declared final, using late-static binding will have no effect. You might want to replace static with self instead.

Late static binding only has effect in subclasses. A final class cannot be extended anymore so late static binding cannot occurr. Consider replacing static:: with self::.

To learn more about late static binding, please refer to the PHP core documentation.

Loading history...
40
    }
41
}
42