komtcho/shot

Build classes for HTTP request

dev-main 2023-01-28 22:37 UTC

This package is not auto-updated.

Last update: 2024-04-25 00:32:32 UTC


README

Calling HTTP requests by class encapsulating

Example:-

<?php

use Komtcho\Shot\Contracts\ShootingGet;
use Komtcho\Shot\Contracts\WithHeaders;
use Komtcho\Shot\Shooting;

class Request extends Shooting implements WithHeaders, ShootingGet
{
    protected $url = 'https://webhook.site/9148264c-19c9-4c35-b0f9-0d71cdec3c9d';

    public function headers(): array
    {
        return [
            'X-First' => 'foo',
            'X-Second' => 'bar',
        ];
    }

    public function query(): array
    {
        return [];
    }
}

// Calling
$request = new Request;
return $request->call();