| Conditions | 2 |
| Paths | 2 |
| Total Lines | 17 |
| Code Lines | 7 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 86 | public function transform( string $segment ): string { |
|
| 16 | /* |
||
| 17 | * Examples: |
||
| 18 | * - %{{(text-align=center)}} |
||
| 19 | */ |
||
| 20 | 86 | preg_match_all( '/%{{(?!<ph )[^{}]*?}}/', $segment, $html, PREG_SET_ORDER ); |
|
| 21 | 86 | foreach ( $html as $pos => $variable ) { |
|
| 22 | //replace subsequent elements excluding already encoded |
||
| 23 | 3 | $segment = preg_replace( |
|
| 24 | 3 | '/' . preg_quote( $variable[ 0 ], '/' ) . '/', |
|
| 25 | 3 | '<ph id="' . $this->getPipeline()->getNextId() . '" ctype="' . CTypeEnum::PERCENT_VARIABLE . '" equiv-text="base64:' . base64_encode( $variable[ 0 ] ) . "\"/>", |
|
| 26 | 3 | $segment, |
|
| 27 | 3 | 1 |
|
| 28 | 3 | ); |
|
| 29 | } |
||
| 30 | |||
| 31 | 86 | return $segment; |
|
| 32 | } |
||
| 33 | } |