-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathRequest.php
More file actions
96 lines (82 loc) · 2.6 KB
/
Copy pathRequest.php
File metadata and controls
96 lines (82 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
declare(strict_types=1);
namespace Saloon\Http;
use LogicException;
use Saloon\Enums\Method;
use Saloon\Traits\Bootable;
use Saloon\Traits\Makeable;
use Saloon\Traits\Macroable;
use Saloon\Traits\HasDebugging;
use Saloon\Traits\Conditionable;
use Saloon\Traits\HasMockClient;
use Saloon\Traits\HandlesPsrRequest;
use Saloon\Traits\ManagesExceptions;
use Saloon\Traits\Auth\AuthenticatesRequests;
use Saloon\Traits\RequestProperties\HasTries;
use Saloon\Traits\Responses\HasCustomResponses;
use Saloon\Traits\Request\CreatesDtoFromResponse;
use Saloon\Traits\RequestProperties\HasRequestProperties;
abstract class Request
{
use CreatesDtoFromResponse;
use AuthenticatesRequests;
use HasRequestProperties;
use HasCustomResponses;
use ManagesExceptions;
use HandlesPsrRequest;
use HasMockClient;
use Conditionable;
use HasDebugging;
use Macroable;
use HasTries;
use Bootable;
use Makeable;
/**
* When non-null, overrides connector / OAuth resolution for absolute endpoints in resolveEndpoint().
* null = inherit. Set true/false on the instance or declare on your request subclass.
*/
public ?bool $allowBaseUrlOverride = null;
/**
* Define the HTTP method.
*/
protected Method $method;
/**
* Get the method of the request.
*/
public function getMethod(): Method
{
if (! isset($this->method)) {
throw new LogicException('Your request is missing a HTTP method. You must add a method property like [protected Method $method = Method::GET]');
}
return $this->method;
}
/**
* Ensure cloned requests do not share mutable object state (query, headers, etc.).
*
* Without this, a shallow clone reuses the same {@see \Saloon\Repositories\ArrayStore}
* instances when they were initialized before cloning, which breaks concurrent pools
* (e.g. paginated requests mutating the same query bag).
*/
public function __clone(): void
{
if (isset($this->query)) {
$this->query = clone $this->query;
}
if (isset($this->headers)) {
$this->headers = clone $this->headers;
}
if (isset($this->config)) {
$this->config = clone $this->config;
}
if (isset($this->delay)) {
$this->delay = clone $this->delay;
}
if (isset($this->middlewarePipeline)) {
$this->middlewarePipeline = clone $this->middlewarePipeline;
}
}
/**
* Define the endpoint for the request.
*/
abstract public function resolveEndpoint(): string;
}