DateTime   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 0
dl 18
loc 18
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromFormat() 9 9 2
A __set_state() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * spindle/types
4
 *
5
 * @license CC0-1.0 (Public Domain) https://creativecommons.org/publicdomain/zero/1.0/
6
 */
7
namespace Spindle\Types\Polyfill;
8
9 View Code Duplication
class DateTime extends \DateTime implements DateTimeInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11 1
    static function createFromFormat($format, $time, /* \DateTimeZone */ $timezone=null)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
12
    {
13 1
        if ($timezone) {
14 1
            $dateTime = \date_create_from_format($format, $time, $timezone);
15 1
        } else {
16 1
            $dateTime = \date_create_from_format($format, $time);
17
        }
18 1
        return new static($dateTime->format('c'));
19
    }
20
21 1
    static function __set_state(array $array)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
22
    {
23 1
        $dateTime = parent::__set_state($array);
24 1
        return new static($dateTime->format('c'));
25
    }
26
}
27