-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* @author Gabriel Zerbib <gabriel@figdice.org> | ||
* @copyright 2004-2015, Gabriel Zerbib. | ||
* @version 2.1.2 | ||
* @package FigDice | ||
* | ||
* This file is part of FigDice. | ||
* http://figdice.org/ | ||
*/ | ||
|
||
namespace figdice\classes\functions; | ||
|
||
use \figdice\FigFunction; | ||
use \figdice\classes\ViewElementTag; | ||
use \figdice\exceptions\FunctionCallException; | ||
|
||
class Function_htmlentities implements FigFunction { | ||
public function __construct() { | ||
} | ||
|
||
/** | ||
* Function's arguments: | ||
* string to escape | ||
* | ||
* @param ViewElement $viewElement | ||
* @param integer $arity | ||
* @param array $arguments | ||
*/ | ||
public function evaluate(ViewElementTag $viewElement, $arity, $arguments) { | ||
if($arity != 1) { | ||
throw new FunctionCallException( | ||
'htmlentities', | ||
'Expects exactly 1 argument.', | ||
$viewElement->getCurrentFile()->getFilename(), | ||
$viewElement->getLineNumber() | ||
); | ||
} | ||
|
||
$string = $arguments[0]; | ||
return htmlentities($string); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters