Passed
Pull Request — master (#22)
by Christopher
01:59
created

xsGYearMonth::fixValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 7
loc 7
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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
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...
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");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal collapse does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
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
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
48