for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace CybozuHttp\Middleware;
use GuzzleHttp\Psr7\StreamDecoratorTrait;
use Psr\Http\Message\StreamInterface;
/**
* @author ochi51 <[email protected]>
*/
class JsonStream implements StreamInterface, \JsonSerializable
{
use StreamDecoratorTrait;
private $stream = null;
$stream
// TODO: Specify return type as mixed when PHP 7.x support is dropped
#[\ReturnTypeWillChange]
public function jsonSerialize()
$contents = (string) $this->getContents();
if ($contents === '') {
return null;
}
$decodedContents = json_decode($contents, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \RuntimeException(
'Error trying to decode response: ' .
json_last_error_msg()
);
return $decodedContents;