| 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 |
||
| 13 | 86 | public function transform( string $segment ): string { |
|
| 14 | 86 | preg_match_all( '/\$\{[^<>\s]+?}/', $segment, $html, PREG_SET_ORDER ); |
|
| 15 | 86 | foreach ( $html as $pos => $snail_variable ) { |
|
| 16 | //check if inside twig variable there is a tag because in this case shouldn't replace the content with PH tag |
||
| 17 | 2 | if ( !strstr( $snail_variable[ 0 ], ConstantEnum::GTPLACEHOLDER ) ) { |
|
| 18 | //replace subsequent elements excluding already encoded |
||
| 19 | 2 | $segment = preg_replace( |
|
| 20 | 2 | '/' . preg_quote( $snail_variable[ 0 ], '/' ) . '/', |
|
| 21 | 2 | '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::DOLLAR_CURLY_BRACKETS . '" equiv-text="base64:' . base64_encode( $snail_variable[ 0 ] ) . '"/>', |
|
| 22 | 2 | $segment, |
|
| 23 | 2 | 1 |
|
| 24 | 2 | ); |
|
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | 86 | return $segment; |
|
| 29 | } |
||
| 30 | } |