xsIDREFS   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 42.86 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 1
cbo 2
dl 12
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isOK() 12 12 3

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
namespace AlgoWeb\xsdTypes;
3
4
use AlgoWeb\xsdTypes\Facets\LengthTrait;
5
6
/**
7
 * The type xsd:IDREFS represents a list of IDREF values separated by whitespace.  There must be at least one IDREF in
8
 * the list.  Each of the IDREF values must match an ID contained in the same XML document.
9
 * @package AlgoWeb\xsdTypes
10
 */
11
class xsIDREFS extends xsAnySimpleType
12
{
13
    use LengthTrait;
14
15
    /**
16
     * Construct.
17
     *
18
     * @param xsIDREF $value
19
     */
20
    public function __construct($value)
21
    {
22
        parent::__construct($value);
23
        $this->setMinLengthFacet(1);
24
    }
25
26 View Code Duplication
    protected function isOK()
27
    {
28
        parent::isOK();
29
        if (!is_array($this->value)) {
30
            throw new \InvalidArgumentException(
31
                'The provided value for ' . __CLASS__ . ' must be an array of type xsIDREF.'
32
            );
33
        }
34
        foreach ($this->value as $v) {
35
            $v->isOKInternal();
36
        }
37
    }
38
}
39