Skip to content

Commit

Permalink
Arrayizable RequesterID
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Jun 16, 2023
1 parent ceb30e5 commit a64a3dd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/SAML2/XML/samlp/RequesterID.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\SAML2\Exception\ArrayValidationException;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\SchemaViolationException;
use SimpleSAML\XML\StringElementTrait;

use function array_key_first;

/**
* Class representing a samlp:RequesterID element.
*
Expand Down Expand Up @@ -58,4 +61,30 @@ public static function fromXML(DOMElement $xml): static

return new static($xml->textContent);
}


/**
* Create a class from an array
*
* @param array $data
* @return static
*/
public static function fromArray(array $data): static
{
Assert::allString($data, ArrayValidationException::class);

$index = array_key_first($data);
return new static($data[$index]);
}


/**
* Create an array from this class
*
* @return array
*/
public function toArray(): array
{
return [$this->getContent()];
}
}

0 comments on commit a64a3dd

Please sign in to comment.