Passed
Push — master ( 4837dc...c02ffb )
by Christopher
01:39
created

xsString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A isOK() 0 8 3
1
<?php
2
namespace AlgoWeb\xsdTypes;
3
4
/**
5
 * The type xsd:string represents a character string that may contain any Unicode character allowed by XML. Certain
6
 * characters, namely the "less than" symbol (<) and the ampersand (&), must be escaped (using the entities
7
 * &lt; and &amp;, respectively) when used in strings in XML instances.
8
 *
9
 * The xsd:string type has a whiteSpace facet of preserve, which means that all whitespace characters
10
 * (spaces, tabs, carriage returns, and line feeds) are preserved by the processor.
11
 * This is in contrast to two types derived from it: normalizedString, and token.
12
 *
13
 * Valid values              Comment
14
 * "This is a string!"
15
 * "Édition française."
16
 * "12.5
17
 *                          :an empty string is valid
18
 * "PB&amp;J"               :when parsed, it will become "PB&J"
19
 * "This
20
 * is on two lines."
21
 * Invalid values           Comment
22
 * "AT&T"                        ampersand must be escaped
23
 * "3 < 4"                    the "less than" symbol must be escaped
24
 * But most of that should be handled by JSM
25
 *
26
 * @package AlgoWeb\xsdTypes
27
 */
28
class xsString extends xsAnySimpleType
29
{
30
    /**
31
     * Construct
32
     *
33
     * @param mixed $value
34
     */
35
    public function __construct($value)
36
    {
37
        parent::__construct($value);
38
        $this->setWhiteSpaceFacet("preserve");
39
        if ('AlgoWeb\xsdTypes\xsString' == get_class($this)) {
40
            $this->fixValue();
41
        }
42
    }
43
44
    protected function isOK()
45
    {
46
        if (is_array($this->__value) || is_object($this->__value)) {
47
            throw new \InvalidArgumentException(
48
                "the provided value for " . __CLASS__ . " is should not be an array or an object: "
49
            );
50
        }
51
    }
52
}
53