Completed
Push — 1.5 ( c5bd05...970e37 )
by Rafał
10:47 queued 10s
created

DateTime   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCurrentDateTime() 0 8 2
A setCurrentDateTime() 0 4 1
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