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