Skip to content

Commit

Permalink
issue #7 - refactor attribute namespace detection and usage
Browse files Browse the repository at this point in the history
try to improve Scrutinizer note :)
  • Loading branch information
mikaelcom committed Mar 7, 2019
1 parent 1ff64b0 commit c1a8e78
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Element.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,11 @@ protected function appendAttributesToElementToSend(\DOMElement $element)
{
if ($this->hasAttributes()) {
foreach ($this->getAttributes() as $attributeName => $attributeValue) {
if (false === strpos($attributeName, ':')) {
$matches = [];
if (0 === preg_match(sprintf('/(%s|%s):/', self::NS_WSSU_NAME, self::NS_WSSE_NAME), $attributeName, $matches)) {
$element->setAttribute($attributeName, $attributeValue);
} else {
list($ns) = explode(':', $attributeName);
if (self::NS_WSSE_NAME === $ns || self::NS_WSSU_NAME === $ns) {
$element->setAttributeNS(self::NS_WSSE_NAME === $ns ? self::NS_WSSE : self::NS_WSSU, $attributeName, $attributeValue);
} else {
$element->setAttribute($attributeName, $attributeValue);
}
$element->setAttributeNS(self::NS_WSSE_NAME === $matches[1] ? self::NS_WSSE : self::NS_WSSU, $attributeName, $attributeValue);
}
}
}
Expand Down

0 comments on commit c1a8e78

Please sign in to comment.