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

xsString::fixValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
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