FromLayer2ToRawXML   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 19
ccs 5
cts 5
cp 1
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 15 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * @author domenico [email protected] / [email protected]
5
 * Date: 05/11/18
6
 * Time: 18.47
7
 *
8
 */
9
10
namespace Matecat\SubFiltering\Filters;
11
12
use Matecat\SubFiltering\Commons\AbstractHandler;
13
use Matecat\SubFiltering\Enum\ConstantEnum;
14
use Matecat\SubFiltering\Utils\Utils;
15
16
/**
17
 * Class FromLayer2ToRawXML
18
 * Same as EncodeToRawXML but from strings coming from layer 2
19
 *
20
 * @package SubFiltering\Filters
21
 */
22
class FromLayer2ToRawXML extends AbstractHandler {
23
24
    private $brokenHTML = false;
0 ignored issues
show
introduced by
The private property $brokenHTML is not used, and could be removed.
Loading history...
25
26 37
    public function transform( $segment ) {
27
28
        //normal control characters must be converted to entities
29 37
        $segment = str_replace(
30 37
                [ "\r\n", "\r", "\n", "\t", "", ],
31
                [
32 37
                        '&#13;&#10;',
33
                        '&#13;',
34
                        '&#10;',
35
                        '&#09;',
36
                        '&#157;',
37
                ], $segment );
38
39
        // now convert the real &nbsp;
40 37
        return str_replace( ConstantEnum::nbspPlaceholder, Utils::unicode2chr( 0Xa0 ), $segment );
41
42
    }
43
44
}