Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
35 | 88 | public function transform( string $segment ): string { |
|
36 | 88 | preg_match_all( '/{{[^<>!{}]+?}}|{%[^<>!%]+?%}|{#[^<>!#]+?#}/', $segment, $html, PREG_SET_ORDER ); |
|
37 | 88 | foreach ( $html as $pos => $twig_variable ) { |
|
38 | //check if inside twig variable there is a tag because in this case shouldn't replace the content with PH tag |
||
39 | 9 | if ( !strstr( $twig_variable[ 0 ], ConstantEnum::GTPLACEHOLDER ) ) { |
|
40 | //replace subsequent elements excluding already encoded |
||
41 | 9 | $segment = preg_replace( |
|
42 | 9 | '/' . preg_quote( $twig_variable[ 0 ], '/' ) . '/', |
|
43 | 9 | '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::TWIG . '" equiv-text="base64:' . base64_encode( $twig_variable[ 0 ] ) . '"/>', |
|
44 | 9 | $segment, |
|
45 | 9 | 1 |
|
46 | 9 | ); |
|
47 | } |
||
48 | } |
||
49 | |||
50 | 88 | return $segment; |
|
51 | } |
||
53 | } |