xsGMonth   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isOK() 4 4 1
A __construct() 5 5 1
A fixValue() 5 5 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\CalenderFactory;
6
use AlgoWeb\xsdTypes\Facets\MinMaxTrait;
7
8
/**
9
 * The type xsd:gMonth represents a specific month that recurs every year. The letter g signifies "Gregorian."
10
 * xsd:gMonth can be used to indicate, for example, that fiscal year-end processing occurs in September of every year.
11
 * To represent a duration of months, use the duration type instead. The format of xsd:gMonth is --MM.
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 xsGMonth 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
        $monthObject = CalenderFactory::fromMonth($this->value);
0 ignored issues
show
Unused Code introduced by
$monthObject is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
39
    }
40
41
    protected function isOK()
42
    {
43
        $this->CheckMinMax(CalenderFactory::fromMonth($this->value));
44
    }
45
}
46