Passed
Pull Request — master (#22)
by Christopher
02:16
created

xsDateTime   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A fixValue() 6 6 1
A isOK() 4 4 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
namespace AlgoWeb\xsdTypes;
4
5
use AlgoWeb\xsdTypes\Facets\MinMaxTrait;
6
7
/**
8
 * The type xsd:dateTime represents a specific date and time in the format CCYY-MM-DDThh:mm:ss.sss, which is a
9
 * concatenation of the date and time forms, separated by a literal letter "T". All of the same rules that apply to
10
 * the date and time types are applicable to xsd:dateTime as well.
11
 *
12
 * An optional time zone expression may be added at the end of the value. The letter Z is used to indicate Coordinated
13
 * Universal Time (UTC). All other time zones are represented by their difference from Coordinated Universal Time
14
 * in the format +hh:mm, or -hh:mm. These values may range from -14:00 to 14:00. For example, US Eastern Standard Time,
15
 * which is five hours behind UTC, is represented as -05:00. If no time zone value is present, it is considered
16
 * unknown; it is not assumed to be UTC.
17
 * @package AlgoWeb\xsdTypes
18
 */
19 View Code Duplication
class xsDateTime extends xsAnySimpleType
1 ignored issue
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...
20
{
21
    use MinMaxTrait;
22
23
    /**
24
     * Construct.
25
     *
26
     * @param string $value
27
     */
28
    public function __construct($value)
29
    {
30
        parent::__construct($value);
31
        $this->setWhiteSpaceFacet('collapse');
32
    }
33
34
    public function fixValue()
35
    {
36
        parent::fixValue();
37
        $v = new \DateTime($this->value);
38
        $this->value = $v->format(\DateTime::RFC3339);
39
    }
40
41
    protected function isOK()
42
    {
43
        $this->CheckMinMax(new \Date($this->value));
44
    }
45
}
46