for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Tuum\Form\Data;
class Escape
{
/**
* @var callable
*/
private $escape = ['Tuum\Form\Data\Escape', 'htmlSafe'];
* @param null|callable $escape
public function __construct($escape = null)
if (is_callable($escape)) {
$this->escape = $escape;
}
* escape for html output.
*
* @param string $string
* @return string
public static function htmlSafe($string)
return is_string($string) ? htmlspecialchars($string, ENT_QUOTES, 'UTF-8') : $string;
* @return mixed
public function __invoke($string)
return $this->escape($string);
* escapes a string using $this->escape.
public function escape($string)
if (is_string($string)) {
$func = $this->escape;
return $func($string);
return $string;
* @return callable
public function getEscape()
return function ($value) {
return $this->escape($value);
};
* @param callable $escape
* @return Escape
public function setEscape($escape)
return $this;