Skip to content

Commit

Permalink
Minor changes and moves
Browse files Browse the repository at this point in the history
  • Loading branch information
runz0rd committed Apr 23, 2017
1 parent 3233965 commit 6684c74
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
12 changes: 12 additions & 0 deletions src/Common/Util/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
6 changes: 3 additions & 3 deletions src/Common/Util/Iteration.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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)) {
Expand Down
9 changes: 2 additions & 7 deletions src/Common/Util/Xml.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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++) {
Expand Down

0 comments on commit 6684c74

Please sign in to comment.