DateTime::createFromFormat()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 2
eloc 6
nc 2
nop 3
crap 2
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