for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php declare(strict_types=1);
namespace Gockets\Adapter;
use Gockets\Contract\AdapterInterface;
use Gockets\Model\Channel;
use stdClass;
final class ChannelAdapter implements AdapterInterface
{
/**
* @param string $content
* @return Channel
*/
public function convertJson(string $content): Channel
$channel = json_decode($content);
return $this->stdClassToChannel($channel);
}
* @return array|Channel[]
public function convertJsonArray(string $content): array
$response = json_decode($content);
$array = [];
if (!empty($response->channels)) {
foreach ($response->channels as $channel) {
$array[] = $this->stdClassToChannel($channel);
return $array;
* @param stdClass $channel
private function stdClassToChannel(stdClass $channel): Channel
return new Channel(
$channel->publisher_token,
$channel->subscriber_token,
$channel->subscriber_message_hook_url,
$channel->listeners
);