- Added some more features to attributes and various Curl wrappers

This commit is contained in:
mcndave committed 2026-07-01 13:24:04 -04:00
1 parent b1adf5a086
commit fe56a1727b
9 files changed
+142 -15

No files matched your search

+49
View File
@@ -0,0 +1,49 @@
<?php
namespace Ulmus\Api\Stream;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
use Ulmus\Api\Common\HttpHeaderEnum;
use Ulmus\Api\Stream\Stream;
use Ulmus\Api\Common\StreamOutputInterface;
# @TODO
class XmlStream extends Stream
{
public function __construct()
{
}
public static function fromContent(mixed $content) : StreamInterface
{
#if ( false === $json = json_encode($content) ) {
# throw new \InvalidArgumentException(sprintf('Json encoding failed with message `%s`.', json_last_error_msg()));
# }
# @TODO !
#return static::fromJsonEncoded($json);
return static::fromXmlEncoded($content);
}
public static function fromXmlEncoded(string $xml) : StreamInterface
{
$obj = static::fromTemp($xml);
$obj->rewind();
return $obj;
}
public function decode(): mixed
{
$content = $this->getContents();
if ($content === "") {
return null;
}
return json_decode(json_encode((array) \simplexml_load_string($content)), true);
}
}