diff options
Diffstat (limited to 'src/Decorators/ReplaceDecorator.php')
-rw-r--r-- | src/Decorators/ReplaceDecorator.php | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/Decorators/ReplaceDecorator.php b/src/Decorators/ReplaceDecorator.php new file mode 100644 index 00000000..e487362c --- /dev/null +++ b/src/Decorators/ReplaceDecorator.php @@ -0,0 +1,34 @@ +<?php + +/** + * PHPPgAdmin6 + */ + +namespace PHPPgAdmin\Decorators; + +class ReplaceDecorator extends Decorator +{ + /** + * @var mixed + */ + public $s; + + public $p; + + public function __construct($str, $params) + { + $this->s = $str; + $this->p = $params; + } + + public function value($fields) + { + $str = $this->s; + + foreach ($this->p as $k => $v) { + $str = \str_replace($k, Decorator::get_sanitized_value($v, $fields), $str); + } + + return $str; + } +} |