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

ODS   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 30
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A escape() 0 4 1
A unescape() 0 10 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