Conditions | 4 |
Paths | 2 |
Total Lines | 17 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | 88 | public function transform( string $segment ): string { |
|
17 | |||
18 | // extract equiv-text attribute |
||
19 | 88 | preg_match_all( '/equiv-text=\"(.*?)\"/', $segment, $equiv_tags ); |
|
20 | |||
21 | 88 | if ( !empty( $equiv_tags[ 0 ] ) ) { |
|
22 | 53 | foreach ( $equiv_tags[ 0 ] as $index => $equiv_tag ) { |
|
23 | 53 | $tag = $equiv_tags[ 1 ][ $index ]; |
|
24 | |||
25 | 53 | if ( strpos( $tag, "base64:" ) === false ) { |
|
26 | 1 | $b = base64_encode( $tag ); |
|
27 | 1 | $segment = str_replace( $equiv_tags[ $index ], 'equiv-text="base64:' . $b . '"', $segment ); |
|
28 | } |
||
29 | } |
||
30 | } |
||
31 | |||
32 | 88 | return $segment; |
|
33 | } |
||
35 |