Passed
Push — master ( 43888e...80ce50 )
by Christopher
02:32 queued 30s
created

xsString   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

3 Methods

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