StandardXEquivTextToMateCatCustomPH   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 13 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * @author domenico [email protected] / [email protected]
5
 * Date: 11/01/19
6
 * Time: 15.11
7
 *
8
 */
9
10
namespace Matecat\SubFiltering\Filters;
11
12
use Matecat\SubFiltering\Commons\AbstractHandler;
13
use Matecat\SubFiltering\Enum\CTypeEnum;
14
15
class StandardXEquivTextToMateCatCustomPH extends AbstractHandler {
16
17 86
    public function transform( $segment ) {
18
19 86
        preg_match_all( '|<x[^>]*?equiv-text="([^"]*?)"[^>]*?/>|', $segment, $xTags, PREG_SET_ORDER );
20 86
        foreach ( $xTags as $group ) {
21 5
            $segment = preg_replace(
22 5
                    '/' . preg_quote( $group[ 0 ], '/' ) . '/',
23 5
                    '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::ORIGINAL_X . '" x-orig="' . base64_encode( $group[ 0 ] ) . '" equiv-text="base64:' . base64_encode( $group[ 1 ] ) . '"/>',
24
                    $segment,
25 5
                    1
26
            );
27
        }
28
29 86
        return $segment;
30
31
    }
32
33
34
}
35
36
37