Completed
Pull Request — develop_3.0 (#565)
by Hura
02:27
created

ODS::escape()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Box\Spout\Common\Helper\Escaper;
4
5
/**
6
 * Class ODS
7
 * Provides functions to escape and unescape data for ODS files
8
 */
9
class ODS implements EscaperInterface
10
{
11
    /**
12
     * Escapes the given string to make it compatible with ODS
13
     *
14
     * @param string $string The string to escape
15
     * @return string The escaped string
16
     */
17 41
    public function escape($string)
18
    {
19 41
        return htmlspecialchars($string, ENT_NOQUOTES | ENT_DISALLOWED);
20
    }
21
22
    /**
23
     * Unescapes the given string to make it compatible with ODS
24
     *
25
     * @param string $string The string to unescape
26
     * @return string The unescaped string
27
     */
28 29
    public function unescape($string)
29
    {
30
        // ==============
31
        // =   WARNING  =
32
        // ==============
33
        // It is assumed that the given string has already had its XML entities decoded.
34
        // This is true if the string is coming from a DOMNode (as DOMNode already decode XML entities on creation).
35
        // Therefore there is no need to call "htmlspecialchars_decode()".
36 29
        return $string;
37
    }
38
}
39