DawidMazurek/php-jsonrpc-server

View on GitHub
src/Response/Response.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types = 1);

namespace DawidMazurek\JsonRpc\Response;

class Response implements JsonRpcResponse
{
    /**
     * @var float
     */
    private $jsonrpc;
    /**
     * @var array
     */
    private $result;
    /**
     * @var int
     */
    private $requestId;

    public function __construct(string $jsonrpc, int $requestId, $result)
    {
        $this->jsonrpc = $jsonrpc;
        $this->requestId = $requestId;
        $this->result = $result;
    }

    public function getPayload(): array
    {
        return [
            'jsonrpc' => $this->jsonrpc,
            'id' => $this->requestId,
            'result' => $this->result
        ];
    }
}