for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace SimpleSAML\XML;
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants;
/**
* Trait grouping common functionality for simple elements with base64 textContent
*
* @package simplesamlphp/xml-common
*/
trait XMLBase64ElementTrait
{
use XMLStringElementTrait;
* Get the content of the element.
* @return string
public function getContent(): string
return $this->sanitizeContent($this->getRawContent());
}
* Get the raw and unsanitized content of the element.
public function getRawContent(): string
return $this->content;
* Sanitize the content of the element.
* @param string $content The unsanitized textContent
* @throws \Exception on failure
protected function sanitizeContent(string $content): string
return str_replace(["\r", "\n", "\t", ' '], '', $content);
* Validate the content of the element.
* @param string $content The value to go in the XML textContent
* @return void
protected function validateContent(string $content): void
// Note: content must already be sanitized before validating
Assert::stringPlausibleBase64($this->sanitizeContent($content));