icingaweb2-module-director/library/vendor/ipl/Html/FormattedString.php

40 lines
765 B
PHP
Raw Normal View History

<?php
2017-10-09 15:23:27 +02:00
namespace dipl\Html;
class FormattedString implements ValidHtml
{
protected $escaped = true;
/** @var ValidHtml[] */
protected $arguments = [];
/** @var ValidHtml */
protected $string;
public function __construct($string, array $arguments = [])
{
$this->string = Util::wantHtml($string);
foreach ($arguments as $key => $val) {
$this->arguments[$key] = Util::wantHtml($val);
}
}
public static function create($string)
{
$args = func_get_args();
2018-05-04 22:55:24 +02:00
array_shift($args);
return new static($string, $args);
}
public function render()
{
return vsprintf(
$this->string->render(),
$this->arguments
);
}
}