Commits

Toro Hill committed f6ac309

Rename HtmlEntities class to HtmlEntitiesEscape.

  • Participants
  • Parent commits 348ddc9

Comments (0)

Files changed (3)

File PhpTemplate/Escape/HtmlEntities.php

-<?php
-/**
- * PHP Template HTML Entitites class.
- *
- * Class for escaping html entities.
- *
- * @author	Toro Hill
- * @link	https://bitbucket.org/torohill/php-template/
- * @license MIT
- */
-namespace PhpTemplate\Escape;
-
-class HtmlEntities implements EscapeInterface{
-	/**
-	 * Escape html entities in a string.
-	 *
-	 * Encodes single and double quotes, replaces any invalid code sequences with U+FFFD
-	 * and handles code as HTML5. Also, input string is treated as UTF-8.
-	 *
-	 * @param	string	$value	The html string to be escaped.
-	 * @return	string			Escaped html input.
-	 */
-	public function escape($value){
-		return htmlentities($value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8');
-	}
-}

File PhpTemplate/Escape/HtmlEntitiesEscape.php

+<?php
+/**
+ * PHP Template HTML Entitites class.
+ *
+ * Class for escaping html entities.
+ *
+ * @author	Toro Hill
+ * @link	https://bitbucket.org/torohill/php-template/
+ * @license MIT
+ */
+namespace PhpTemplate\Escape;
+
+class HtmlEntitiesEscape implements EscapeInterface{
+	/**
+	 * Escape html entities in a string.
+	 *
+	 * Encodes single and double quotes, replaces any invalid code sequences with U+FFFD
+	 * and handles code as HTML5. Also, input string is treated as UTF-8.
+	 *
+	 * @param	string	$value	The html string to be escaped.
+	 * @return	string			Escaped html input.
+	 */
+	public function escape($value){
+		return htmlentities($value, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML5, 'UTF-8');
+	}
+}
 
 ### Escaping Values
 
-Objects which implement `\PhpTemplate\Escape\EscapeInterface` are added to the configuration using `Template::addEscape()` (or with the `Template::setConfig()`). Then `$this->escape()` is then called from within a template to escape a value. The `\PhpTemplate\Escape\HtmlEntites` class can be used for escaping HTML entities.
+Objects which implement `\PhpTemplate\Escape\EscapeInterface` are added to the configuration using `Template::addEscape()` (or with the `Template::setConfig()`). Then `$this->escape()` is then called from within a template to escape a value. The `\PhpTemplate\Escape\HtmlEntitesEscape` class can be used for escaping HTML entities.
 
 For example:
 
 		require_once 'vendor/autoload.php'; // Require composer autoloader.
 
 		use \PhpTemplate\Template;
-		use \PhpTemplate\Escape\HtmlEntities;
+		use \PhpTemplate\Escape\HtmlEntitiesEscape;
 
-		Template::addEscape(new HtmlEntities);
+		Template::addEscape(new HtmlEntitiesEscape);
 
 		$t = new \PhpTemplate\Template('hello.html.php');
 		$t->greeting = '<b>Hello<b>';