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

xsGYearMonth   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A fixValue() 7 7 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:gYearMonth represents a specific month of a specific year. The letter g signifies "Gregorian." The
9
 * format of xsd:gYearMonth is CCYY-MM. No left truncation is allowed on either part. To represents years later than
10
 * 9999, additional digits can be added to the left of the year value. To represent years before 0001,
11
 * a preceding minus sign ("-") is permitted.
12
 *
13
 * An optional time zone expression may be added at the end of the value. The letter Z is used to indicate Coordinated
14
 * Universal Time (UTC). All other time zones are represented by their difference from Coordinated Universal Time in
15
 * the format +hh:mm, or -hh:mm. These values may range from -14:00 to 14:00. For example, US Eastern Standard Time,
16
 * which is five hours behind UTC, is represented as -05:00. If no time zone value is present, it is considered
17
 * unknown; it is not assumed to be UTC.
18
 * @package AlgoWeb\xsdTypes
19
 */
20 View Code Duplication
class xsGYearMonth extends xsAnySimpleType
21
{
22
    use MinMaxTrait;
23
24
    /**
25
     * Construct.
26
     *
27
     * @param string $value
28
     */
29
    public function __construct($value)
30
    {
31
        parent::__construct($value);
32
        $this->setWhiteSpaceFacet('collapse');
33
    }
34
35
    public function fixValue()
36
    {
37
        parent::fixValue();
38
        $v = new \DateTime($this->value);
39
        //TODO: TechDebt, This needs to format to
0 ignored issues
show
Coding Style Best Practice introduced by
Comments for TODO tasks are often forgotten in the code; it might be better to use a dedicated issue tracker.
Loading history...
40
        $this->value = $v->format(\DateTime::RFC3339);
41
    }
42
43
    protected function isOK()
44
    {
45
        $this->CheckMinMax(new \Date($this->value));
46
    }
47
}
48