diff --git a/src/Common/Util/File.php b/src/Common/Util/File.php index 0e6c0e1..ae0df66 100644 --- a/src/Common/Util/File.php +++ b/src/Common/Util/File.php @@ -23,4 +23,16 @@ public static function write($filePath, $filename, $data) { fwrite($fh, $data); fclose($fh); } + + /** + * @param string $filename + * @return string + */ + public static function read($filename) { + $contents = file_get_contents($filename); + $contents = str_replace("\n", '', $contents); + $contents = str_replace("\r", '', $contents); + $contents = str_replace(' ', '', $contents); + return $contents; + } } \ No newline at end of file diff --git a/src/Common/Util/Iteration.php b/src/Common/Util/Iteration.php index 3d749f0..a1555a7 100644 --- a/src/Common/Util/Iteration.php +++ b/src/Common/Util/Iteration.php @@ -53,7 +53,7 @@ public static function findValueInObject($source, $name, $defaultValue) { return $value; } - public function findValueInSimpleXmlElement(\SimpleXMLElement $source, $name, $defaultValue) { + public function findValueInSimpleXmlElement($source, $name, $defaultValue) { $value = self::findValueInObject($source, $name, $defaultValue); if($value instanceof \SimpleXMLElement && $value->children()->count() === 0) { $value = (string) $value; @@ -128,7 +128,7 @@ public static function assign($source, $key, $value) { * @param string $needle * @return string|null */ - public static function strposArray(array $haystackArray, $needle) { + public static function strposArray($haystackArray, $needle) { $result = null; foreach($haystackArray as $haystack) { if(strpos($haystack, $needle) !== false) { @@ -144,7 +144,7 @@ public static function strposArray(array $haystackArray, $needle) { * @param string $regex * @return string|null */ - public static function regexArray(array $haystackArray, $regex) { + public static function regexArray($haystackArray, $regex) { $result = null; foreach($haystackArray as $haystack) { if(preg_match($regex, $haystack, $matches)) { diff --git a/src/Common/Util/Xml.php b/src/Common/Util/Xml.php index 6d5835a..5a7dbd1 100644 --- a/src/Common/Util/Xml.php +++ b/src/Common/Util/Xml.php @@ -30,12 +30,7 @@ public static function isValidElementName($name) { * @return string */ public static function loadFromFile($filename) { - $contents = file_get_contents($filename); - $contents = str_replace("\n", '', $contents); - $contents = str_replace("\r", '', $contents); - $xml = str_replace(' ', '', $contents); - - return $xml; + return File::read($filename); } /** @@ -44,7 +39,7 @@ public static function loadFromFile($filename) { * @param string $key * @return bool */ - public static function isDomNodeArray(\DOMNode $parentElement, $key) { + public static function isDomNodeArray($parentElement, $key) { $result = false; $keyCount = 0; for($i = 0; $i < $parentElement->childNodes->length; $i++) {