xsENTITIES   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 40.74 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

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