xsYearMonthDuration   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 9
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A fixValue() 6 6 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\AxillaryClasses\XMLDateInterval;
6
7
/**
8
 * The type xsd:yearMonthDuration represents a duration of time expressed as a number of years and months. The format
9
 * of xsd:yearMonthDuration is PnYnM, where P is a literal value that starts the expression, nY is the number of years
10
 * followed by a literal Y, nM is the number of months followed by a literal M. The following rules apply to
11
 * xsd:yearMonthDuration values:.
12
 *
13
 * - Either of these numbers and corresponding designators may be absent if they are equal to 0, but at least
14
 *   one number and designator must appear.
15
 * - The numbers may be any unsigned integer.
16
 * - A minus sign may appear before the P to specify a negative duration.
17
 * Note that this type was added to the XML Schema namespace as a result of XPath 2.0. It was not in the original XML
18
 * Schema 1.0 specification and is therefore not supported for use in XML Schema 1.0 schemas.
19
 * @package AlgoWeb\xsdTypes
20
 */
21 View Code Duplication
class xsYearMonthDuration extends xsDuration
22
{
23
    public function fixValue()
24
    {
25
        parent::fixValue();
26
        $dateIntervalObject = new XMLDateInterval($this->value, 'PnYnM');
27
        $this->value = $dateIntervalObject->__toString();
28
    }
29
}
30