for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace drupol\Yaroc\Plugin;
use drupol\Yaroc\Http\AbstractClient;
use Http\Client\Exception\HttpException;
use Psr\Http\Message\ResponseInterface;
abstract class AbstractMethodPlugin extends AbstractClient implements MethodPluginInterface
{
/**
* The endpoint.
*
* @var string
*/
private $endpoint = '';
* The parameters.
* @var array
private $parameters = [];
* {@inheritdoc}
public function request() :ResponseInterface
$parameters = [
'jsonrpc' => '2.0',
'id' => uniqid($this->getMethod() . '_'),
'params' => $this->getParameters(),
'method' => $this->getMethod(),
];
try {
$response = $this->getHttpClient()->sendRequest(
$this->getMessageFactory()->createRequest(
'POST',
$this->getEndpoint(),
[],
json_encode(
$parameters
)
);
} catch (HttpException $exception) {
throw new \Exception($exception->getMessage());
} catch (\Exception $exception) {
}
return $response;
public function withEndPoint(string $endpoint) :MethodPluginInterface
$clone = clone $this;
$clone->endpoint = $endpoint;
return $clone;
public function getEndPoint() :string
return $this->endpoint;
public function withParameters(array $parameters) :MethodPluginInterface
$clone->parameters = $parameters;
public function getParameters() :array
return $this->parameters;
public function getMethod() :string
return $this::METHOD;