Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor getXmlValue out to a Helper class. Rename OAuthHelper for co…
…nsistency
- Loading branch information
Showing
4 changed files
with
77 additions
and
58 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
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
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
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,41 @@ | ||
<?php | ||
/** | ||
* Xml.php | ||
* 20-May-2020 | ||
* | ||
* PHP Version 5 | ||
* | ||
* @category Xml | ||
* @package Xml | ||
* @author Ken Guest <ken@linux.ie> | ||
* @license GPL (see http://www.gnu.org/licenses/gpl.txt) | ||
* @version CVS: <cvs_id> | ||
* @link Xml.php | ||
* @todo | ||
*/ | ||
|
||
class Services_OpenStreetMap_Helper_Xml | ||
{ | ||
/** | ||
* Given SimpleXMLElement, retrieve tag value. | ||
* | ||
* @param SimpleXMLElement $xml Object | ||
* @param string $tag name of tag | ||
* @param string $attribute name of attribute | ||
* @param mixed $default default value, optional | ||
* | ||
* @return string | ||
*/ | ||
public function getValue( | ||
SimpleXMLElement $xml, | ||
string $tag, | ||
string $attribute, | ||
$default = null | ||
):?string { | ||
$obj = $xml->xpath('//' . $tag); | ||
if (empty($obj)) { | ||
return $default; | ||
} | ||
return $obj[0]->attributes()->$attribute; | ||
} | ||
} |