From bec5f2b1502f76bc5fb031658a27a4f2bd5d2830 Mon Sep 17 00:00:00 2001 From: Josh Schroeder Date: Sun, 1 Jun 2014 21:46:30 -0500 Subject: [PATCH] Added static properties for the default config variables --- lib/Caxy/HtmlDiff/HtmlDiff.php | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/Caxy/HtmlDiff/HtmlDiff.php b/lib/Caxy/HtmlDiff/HtmlDiff.php index 7db9edc..030933d 100644 --- a/lib/Caxy/HtmlDiff/HtmlDiff.php +++ b/lib/Caxy/HtmlDiff/HtmlDiff.php @@ -4,6 +4,10 @@ class HtmlDiff { + public static $defaultSpecialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'); + public static $defaultSpecialCaseChars = array('.', ',', '(', ')', '\''); + public static $defaultGroupDiffs = true; + private $content; private $oldText; private $newText; @@ -13,19 +17,27 @@ class HtmlDiff private $encoding; private $specialCaseOpeningTags = array(); private $specialCaseClosingTags = array(); - private $specialCaseTags = array('strong', 'b', 'i', 'big', 'small', 'u', 'sub', 'sup', 'strike', 's', 'p'); - private $specialCaseChars = array('.', ',', '(', ')', '\''); - private $groupDiffs = true; - - public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = array(), $groupDiffs = true) - { + private $specialCaseTags; + private $specialCaseChars; + private $groupDiffs; + + public function __construct($oldText, $newText, $encoding = 'UTF-8', $specialCaseTags = null, $groupDiffs = null) + { + if ($specialCaseTags === null) { + $specialCaseTags = static::$defaultSpecialCaseTags; + } + + if ($groupDiffs === null) { + $groupDiffs = static::$defaultGroupDiffs; + } + $this->oldText = $this->purifyHtml(trim($oldText)); $this->newText = $this->purifyHtml(trim($newText)); $this->encoding = $encoding; $this->content = ''; $this->groupDiffs = $groupDiffs; - $this->setSpecialCaseTags($specialCaseTags); + $this->setSpecialCaseChars(static::$defaultSpecialCaseChars); } public function setSpecialCaseChars(array $chars)