Skip to content

Commit 685d54c

Browse files
committed
PHPDoc
1 parent 94447c3 commit 685d54c

File tree

3 files changed

+60
-5
lines changed

3 files changed

+60
-5
lines changed

src/Buildable.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,42 +23,85 @@ protected function returnAndResetBuilderState()
2323
return $request;
2424
}
2525

26+
/**
27+
* Add authentication to request
28+
*
29+
* @param string $type Authentication type
30+
* @param array|string $credentials Authentication credentials
31+
* @return $this
32+
*/
2633
public function auth($type, $credentials)
2734
{
2835
$this->applyRequestOptions([$type => $credentials]);
2936
return $this;
3037
}
3138

39+
/**
40+
* Add HTTP basic auth to request
41+
*
42+
* @param array|string $credentials "Authentication credentials"
43+
* @return $this
44+
*/
3245
public function authBasic($credentials)
3346
{
3447
$this->applyRequestOptions(["auth_basic" => $credentials]);
3548
return $this;
3649
}
3750

51+
/**
52+
* Add Bearer token to request
53+
*
54+
* @param string $credentials "Bearer token"
55+
* @return $this
56+
*/
3857
public function authBearer($credentials)
3958
{
4059
$this->applyRequestOptions(["auth_bearer" => $credentials]);
4160
return $this;
4261
}
4362

63+
/**
64+
* Add headers to request
65+
*
66+
* @param array $headers Headers
67+
* @return $this
68+
*/
4469
public function headers($headers)
4570
{
4671
$this->applyRequestOptions(["headers" => $headers]);
4772
return $this;
4873
}
4974

75+
/**
76+
* Add body to request
77+
*
78+
* @param array|string|resource|\Traversable|\Closure $body Request body
79+
* @return $this
80+
*/
5081
public function body($body)
5182
{
5283
$this->applyRequestOptions(["body" => $body]);
5384
return $this;
5485
}
5586

87+
/**
88+
* Add JSON to request
89+
*
90+
* @param array|\JsonSerializable $json JSON-compatible value
91+
* @return $this
92+
*/
5693
public function json($json)
5794
{
5895
$this->applyRequestOptions(["json" => $json]);
5996
return $this;
6097
}
6198

99+
/**
100+
* Add query string values to request
101+
*
102+
* @param array $query Query string values
103+
* @return $this
104+
*/
62105
public function query($query)
63106
{
64107
$this->applyRequestOptions(["query" => $query]);

src/HttpClient.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
use Symfony\Component\HttpClient\HttpClient as Client;
77

88
/**
9-
* @method get(string $url, array $arguments) Send a GET request
10-
* @method head(string $url, array $arguments) Send a HEAD request
11-
* @method post(string $url, array $arguments) Send a POST request
12-
* @method put(string $url, array $arguments) Send a PUT request
13-
* @method delete(string $url, array $arguments) Send a DELETE request
9+
* @method Response get(string $url, array $arguments) Send a GET request
10+
* @method Response head(string $url, array $arguments) Send a HEAD request
11+
* @method Response post(string $url, array $arguments) Send a POST request
12+
* @method Response put(string $url, array $arguments) Send a PUT request
13+
* @method Response delete(string $url, array $arguments) Send a DELETE request
1414
*/
1515
class HttpClient
1616
{

src/Response.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
use Symfony\Component\HttpClient\Exception\JsonException;
66

7+
/**
8+
* @method int getStatusCode() Get response status code
9+
* @method array getHeaders(bool $throw = true) Get response headers
10+
* @method array toArray(bool $throw = true) Get array from response
11+
* @method array|mixed|null getInfo(string $type = null) Get info from transport layer
12+
*/
713
class Response
814
{
915
protected $baseResponse;
@@ -23,6 +29,12 @@ public function toCollection()
2329
return collect($this->baseResponse->toArray());
2430
}
2531

32+
/**
33+
* Get body of response, or collection, if response is JSON-compatible
34+
*
35+
* @param bool $throw
36+
* @return \Illuminate\Support\Collection|string
37+
*/
2638
public function getContent($throw = true)
2739
{
2840
try {

0 commit comments

Comments
 (0)