| 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 | 2 | public function transform( string $segment ): string { |
|
| 36 | 2 | preg_match_all( '/{[^<>{} ]+?}/', $segment, $html, PREG_SET_ORDER ); |
|
| 37 | 2 | 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 | 2 | if ( !strstr( $twig_variable[ 0 ], ConstantEnum::GTPLACEHOLDER ) ) { |
|
| 40 | //replace subsequent elements excluding already encoded |
||
| 41 | 2 | $segment = preg_replace( |
|
| 42 | 2 | '/' . preg_quote( $twig_variable[ 0 ], '/' ) . '/', |
|
| 43 | 2 | '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::CURLY_BRACKETS . '" equiv-text="base64:' . base64_encode( $twig_variable[ 0 ] ) . '"/>', |
|
| 44 | 2 | $segment, |
|
| 45 | 2 | 1 |
|
| 46 | 2 | ); |
|
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | 2 | return $segment; |
|
| 51 | } |
||
| 53 | } |