Conditions | 2 |
Paths | 1 |
Total Lines | 10 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
18 | public static function replace($text, $params = []) { |
||
19 | $allParams = $params; |
||
20 | return preg_replace_callback('/{([^}]+)}/', function ($m) use ($allParams) { |
||
21 | // skip if is not set |
||
22 | if(isset($allParams[$m[1]])){ |
||
23 | return $allParams[$m[1]]; |
||
24 | } |
||
25 | \Yii::error('Failed to replace field: '.$m[1] ,__METHOD__); |
||
26 | return "{".$m[1]."}"; |
||
27 | }, $text); |
||
28 | } |
||
43 |