Skip to content

Commit de8df64

Browse files
committed
Adding support for Saloon v3
1 parent cba27ba commit de8df64

19 files changed

Lines changed: 37 additions & 116 deletions

.github/workflows/php-cs-fixer.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- 'v1'
77
- 'v2'
8+
- 'v3'
89
pull_request:
910
branches:
1011
- '*'

.github/workflows/tests.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- 'v1'
77
- 'v2'
8+
- 'v3'
89
pull_request:
910
branches:
1011
- '*'

.php-cs-fixer.dist.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,8 @@
4141
'blank_line_after_opening_tag' => true,
4242
'single_import_per_statement' => true,
4343
'mb_str_functions' => true,
44+
'no_superfluous_phpdoc_tags' => true,
45+
'no_blank_lines_after_phpdoc' => true,
46+
'no_empty_phpdoc' => true,
47+
'phpdoc_trim' => true,
4448
])->setFinder($finder);

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"minimum-stability": "stable",
1919
"require": {
2020
"php": "^8.1",
21-
"saloonphp/saloon": "^2.0"
21+
"saloonphp/saloon": "^3.0.0-beta.4"
2222
},
2323
"require-dev": {
2424
"friendsofphp/php-cs-fixer": "^3.13",

src/Contracts/Cacheable.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,11 @@ interface Cacheable
88
{
99
/**
1010
* Resolve the driver responsible for caching
11-
*
12-
* @return \Saloon\CachePlugin\Contracts\Driver
1311
*/
1412
public function resolveCacheDriver(): Driver;
1513

1614
/**
1715
* Define the cache expiry in seconds
18-
*
19-
* @return int
2016
*/
2117
public function cacheExpiryInSeconds(): int;
2218
}

src/Contracts/Driver.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,18 @@ interface Driver
1111
{
1212
/**
1313
* Store the cached response on the driver.
14-
*
15-
* @param string $key
16-
* @param CachedResponse $cachedResponse
17-
* @return void
1814
*/
1915
public function set(string $key, CachedResponse $cachedResponse): void;
2016

2117
/**
2218
* Get the cached response from the driver.
2319
*
24-
* @param string $cacheKey
2520
* @return RecordedResponse|null
2621
*/
2722
public function get(string $cacheKey): ?CachedResponse;
2823

2924
/**
3025
* Delete the cached response.
31-
*
32-
* @param string $cacheKey
33-
* @return void
3426
*/
3527
public function delete(string $cacheKey): void;
3628
}

src/Data/CachedResponse.php

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66

77
use DateTimeImmutable;
88
use Saloon\Data\RecordedResponse;
9-
use Saloon\Http\Faking\SimulatedResponsePayload;
10-
use Saloon\Contracts\SimulatedResponsePayload as SimulatedResponsePayloadContract;
9+
use Saloon\Http\Faking\FakeResponse;
10+
use Saloon\Contracts\FakeResponse as FakeResponseContract;
1111

1212
class CachedResponse
1313
{
1414
/**
1515
* Constructor
16-
*
17-
* @param \Saloon\Data\RecordedResponse $recordedResponse
18-
* @param \DateTimeImmutable $expiresAt
19-
* @param int $ttl
2016
*/
2117
public function __construct(
2218
readonly public RecordedResponse $recordedResponse,
@@ -28,8 +24,6 @@ public function __construct(
2824

2925
/**
3026
* Check if the response has expired.
31-
*
32-
* @return bool
3327
*/
3428
public function hasExpired(): bool
3529
{
@@ -38,24 +32,20 @@ public function hasExpired(): bool
3832

3933
/**
4034
* Check if the response has not expired.
41-
*
42-
* @return bool
4335
*/
4436
public function hasNotExpired(): bool
4537
{
4638
return ! $this->hasExpired();
4739
}
4840

4941
/**
50-
* Create a simulated response payload
51-
*
52-
* @return \Saloon\Contracts\SimulatedResponsePayload
42+
* Create a fake response
5343
*/
54-
public function getSimulatedResponsePayload(): SimulatedResponsePayloadContract
44+
public function getFakeResponse(): FakeResponseContract
5545
{
5646
$response = $this->recordedResponse;
5747

58-
return new SimulatedResponsePayload(
48+
return new FakeResponse(
5949
body: $response->data,
6050
status: $response->statusCode,
6151
headers: $response->headers

src/Drivers/FlysystemDriver.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ class FlysystemDriver implements Driver
1313
{
1414
/**
1515
* Constructor
16-
*
17-
* @param \League\Flysystem\Filesystem $store
1816
*/
1917
public function __construct(
2018
protected Filesystem $store,
@@ -25,9 +23,6 @@ public function __construct(
2523
/**
2624
* Store the cached response on the driver.
2725
*
28-
* @param string $key
29-
* @param \Saloon\CachePlugin\Data\CachedResponse $cachedResponse
30-
* @return void
3126
* @throws \League\Flysystem\FilesystemException
3227
*/
3328
public function set(string $key, CachedResponse $cachedResponse): void
@@ -38,8 +33,6 @@ public function set(string $key, CachedResponse $cachedResponse): void
3833
/**
3934
* Get the cached response from the driver.
4035
*
41-
* @param string $cacheKey
42-
* @return \Saloon\CachePlugin\Data\CachedResponse|null
4336
* @throws \League\Flysystem\FilesystemException
4437
*/
4538
public function get(string $cacheKey): ?CachedResponse
@@ -60,8 +53,6 @@ public function get(string $cacheKey): ?CachedResponse
6053
/**
6154
* Delete the cached response
6255
*
63-
* @param string $cacheKey
64-
* @return void
6556
* @throws \League\Flysystem\FilesystemException
6657
*/
6758
public function delete(string $cacheKey): void

src/Drivers/LaravelCacheDriver.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ class LaravelCacheDriver implements Driver
1212
{
1313
/**
1414
* Constructor
15-
*
16-
* @param \Illuminate\Contracts\Cache\Repository $store
1715
*/
1816
public function __construct(
1917
protected Repository $store,
@@ -24,9 +22,6 @@ public function __construct(
2422
/**
2523
* Store the cached response on the driver.
2624
*
27-
* @param string $key
28-
* @param \Saloon\CachePlugin\Data\CachedResponse $cachedResponse
29-
* @return void
3025
* @throws \Psr\SimpleCache\InvalidArgumentException
3126
*/
3227
public function set(string $key, CachedResponse $cachedResponse): void
@@ -37,8 +32,6 @@ public function set(string $key, CachedResponse $cachedResponse): void
3732
/**
3833
* Get the cached response from the driver.
3934
*
40-
* @param string $cacheKey
41-
* @return \Saloon\CachePlugin\Data\CachedResponse|null
4235
* @throws \Psr\SimpleCache\InvalidArgumentException
4336
*/
4437
public function get(string $cacheKey): ?CachedResponse
@@ -55,8 +48,6 @@ public function get(string $cacheKey): ?CachedResponse
5548
/**
5649
* Delete the cached response.
5750
*
58-
* @param string $cacheKey
59-
* @return void
6051
* @throws \Psr\SimpleCache\InvalidArgumentException
6152
*/
6253
public function delete(string $cacheKey): void

src/Drivers/PsrCacheDriver.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ class PsrCacheDriver implements Driver
1515
{
1616
/**
1717
* Constructor
18-
*
19-
* @param CacheInterface $store
2018
*/
2119
public function __construct(
2220
protected CacheInterface $store,
@@ -27,9 +25,6 @@ public function __construct(
2725
/**
2826
* Store the cached response on the driver.
2927
*
30-
* @param string $key
31-
* @param \Saloon\CachePlugin\Data\CachedResponse $cachedResponse
32-
* @return void
3328
* @throws \Psr\SimpleCache\InvalidArgumentException
3429
*/
3530
public function set(string $key, CachedResponse $cachedResponse): void
@@ -40,8 +35,6 @@ public function set(string $key, CachedResponse $cachedResponse): void
4035
/**
4136
* Get the cached response from the driver.
4237
*
43-
* @param string $cacheKey
44-
* @return CachedResponse|null
4538
* @throws \Psr\SimpleCache\InvalidArgumentException
4639
*/
4740
public function get(string $cacheKey): ?CachedResponse
@@ -58,8 +51,6 @@ public function get(string $cacheKey): ?CachedResponse
5851
/**
5952
* Delete the cached response.
6053
*
61-
* @param string $cacheKey
62-
* @return void
6354
* @throws \Psr\SimpleCache\InvalidArgumentException
6455
*/
6556
public function delete(string $cacheKey): void

0 commit comments

Comments
 (0)