RestoreEquivText   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A transform() 0 17 4
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * @author domenico [email protected] / [email protected]
5
 * Date: 13/05/19
6
 * Time: 19.37
7
 *
8
 */
9
10
namespace Matecat\SubFiltering\Filters;
11
12
use Matecat\SubFiltering\Commons\AbstractHandler;
13
14
class RestoreEquivText extends AbstractHandler {
15
16 68
    public function transform( $segment ) {
17
18
        // extract equiv-text attribute
19 68
        preg_match_all('/equiv-text=\"(.*?)\"/', $segment, $equiv_tags);
20
21 68
        if(!empty($equiv_tags[0])){
22 9
            foreach ($equiv_tags[0] as $index => $equiv_tag){
23 9
                $tag = $equiv_tags[1][$index];
24
25 9
                if (strpos($tag, "base64:") !== false) {
26 1
                    $b = base64_decode(str_replace("base64:", "", $tag));
27 1
                    $segment = str_replace($equiv_tags[$index], 'equiv-text="'.$b.'"', $segment);
28
                }
29
            }
30
        }
31
32 68
        return $segment;
33
    }
34
}
35