Skip to content

Commit 3fd1725

Browse files
authored
Remove dependency to http-client (#325)
* Remove dependency to http-client * Use "minimum-stability":"dev"
1 parent 3cf327d commit 3fd1725

11 files changed

+27
-28
lines changed

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"require": {
1111
"php": "^7.2.5",
1212
"ext-json": "*",
13-
"async-aws/core": "^0.4",
14-
"symfony/http-client-contracts": "^1.0 || ^2.0"
13+
"async-aws/core": "^0.5"
1514
},
1615
"extra": {
1716
"branch-alias": {

src/LambdaClient.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function addLayerVersionPermission($input): AddLayerVersionPermissionResp
3636
{
3737
$response = $this->getResponse(AddLayerVersionPermissionRequest::create($input)->request());
3838

39-
return new AddLayerVersionPermissionResponse($response, $this->httpClient);
39+
return new AddLayerVersionPermissionResponse($response);
4040
}
4141

4242
/**
@@ -58,7 +58,7 @@ public function invoke($input): InvocationResponse
5858
{
5959
$response = $this->getResponse(InvocationRequest::create($input)->request());
6060

61-
return new InvocationResponse($response, $this->httpClient);
61+
return new InvocationResponse($response);
6262
}
6363

6464
/**
@@ -81,7 +81,7 @@ public function listLayerVersions($input): ListLayerVersionsResponse
8181
$input = ListLayerVersionsRequest::create($input);
8282
$response = $this->getResponse($input->request());
8383

84-
return new ListLayerVersionsResponse($response, $this->httpClient, $this, $input);
84+
return new ListLayerVersionsResponse($response, $this, $input);
8585
}
8686

8787
/**
@@ -103,7 +103,7 @@ public function publishLayerVersion($input): PublishLayerVersionResponse
103103
{
104104
$response = $this->getResponse(PublishLayerVersionRequest::create($input)->request());
105105

106-
return new PublishLayerVersionResponse($response, $this->httpClient);
106+
return new PublishLayerVersionResponse($response);
107107
}
108108

109109
protected function getServiceCode(): string

src/Result/AddLayerVersionPermissionResponse.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
namespace AsyncAws\Lambda\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Result;
6-
use Symfony\Contracts\HttpClient\HttpClientInterface;
7-
use Symfony\Contracts\HttpClient\ResponseInterface;
87

98
class AddLayerVersionPermissionResponse extends Result
109
{
@@ -32,9 +31,9 @@ public function getStatement(): ?string
3231
return $this->Statement;
3332
}
3433

35-
protected function populateResult(ResponseInterface $response, HttpClientInterface $httpClient): void
34+
protected function populateResult(Response $response): void
3635
{
37-
$data = $response->toArray(false);
36+
$data = $response->toArray();
3837

3938
$this->Statement = isset($data['Statement']) ? (string) $data['Statement'] : null;
4039
$this->RevisionId = isset($data['RevisionId']) ? (string) $data['RevisionId'] : null;

src/Result/InvocationResponse.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
namespace AsyncAws\Lambda\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Result;
6-
use Symfony\Contracts\HttpClient\HttpClientInterface;
7-
use Symfony\Contracts\HttpClient\ResponseInterface;
87

98
class InvocationResponse extends Result
109
{
@@ -72,15 +71,15 @@ public function getStatusCode(): ?int
7271
return $this->StatusCode;
7372
}
7473

75-
protected function populateResult(ResponseInterface $response, HttpClientInterface $httpClient): void
74+
protected function populateResult(Response $response): void
7675
{
7776
$this->StatusCode = $response->getStatusCode();
78-
$headers = $response->getHeaders(false);
77+
$headers = $response->getHeaders();
7978

8079
$this->FunctionError = $headers['x-amz-function-error'][0] ?? null;
8180
$this->LogResult = $headers['x-amz-log-result'][0] ?? null;
8281
$this->ExecutedVersion = $headers['x-amz-executed-version'][0] ?? null;
8382

84-
$this->Payload = $response->getContent(false);
83+
$this->Payload = $response->getContent();
8584
}
8685
}

src/Result/ListLayerVersionsResponse.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,11 @@
22

33
namespace AsyncAws\Lambda\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Result;
67
use AsyncAws\Lambda\Input\ListLayerVersionsRequest;
78
use AsyncAws\Lambda\LambdaClient;
89
use AsyncAws\Lambda\ValueObject\LayerVersionsListItem;
9-
use Symfony\Contracts\HttpClient\HttpClientInterface;
10-
use Symfony\Contracts\HttpClient\ResponseInterface;
1110

1211
class ListLayerVersionsResponse extends Result implements \IteratorAggregate
1312
{
@@ -107,9 +106,9 @@ public function getNextMarker(): ?string
107106
return $this->NextMarker;
108107
}
109108

110-
protected function populateResult(ResponseInterface $response, HttpClientInterface $httpClient): void
109+
protected function populateResult(Response $response): void
111110
{
112-
$data = $response->toArray(false);
111+
$data = $response->toArray();
113112

114113
$this->NextMarker = isset($data['NextMarker']) ? (string) $data['NextMarker'] : null;
115114
$this->LayerVersions = empty($data['LayerVersions']) ? [] : (function (array $json): array {

src/Result/PublishLayerVersionResponse.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22

33
namespace AsyncAws\Lambda\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Result;
67
use AsyncAws\Lambda\Enum\Runtime;
78
use AsyncAws\Lambda\ValueObject\LayerVersionContentOutput;
8-
use Symfony\Contracts\HttpClient\HttpClientInterface;
9-
use Symfony\Contracts\HttpClient\ResponseInterface;
109

1110
class PublishLayerVersionResponse extends Result
1211
{
@@ -111,9 +110,9 @@ public function getVersion(): ?string
111110
return $this->Version;
112111
}
113112

114-
protected function populateResult(ResponseInterface $response, HttpClientInterface $httpClient): void
113+
protected function populateResult(Response $response): void
115114
{
116-
$data = $response->toArray(false);
115+
$data = $response->toArray();
117116

118117
$this->Content = empty($data['Content']) ? null : new LayerVersionContentOutput([
119118
'Location' => isset($data['Content']['Location']) ? (string) $data['Content']['Location'] : null,

tests/Integration/LambdaClientTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
use AsyncAws\Core\Credentials\NullProvider;
66
use AsyncAws\Lambda\Input\AddLayerVersionPermissionRequest;
77
use AsyncAws\Lambda\Input\InvocationRequest;
8-
use AsyncAws\Lambda\Input\LayerVersionContentInput;
98
use AsyncAws\Lambda\Input\ListLayerVersionsRequest;
109
use AsyncAws\Lambda\Input\PublishLayerVersionRequest;
1110
use AsyncAws\Lambda\LambdaClient;
11+
use AsyncAws\Lambda\ValueObject\LayerVersionContentInput;
1212
use PHPUnit\Framework\TestCase;
1313

1414
class LambdaClientTest extends TestCase

tests/Unit/Result/AddLayerVersionPermissionResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\Lambda\Tests\Unit\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
67
use AsyncAws\Core\Test\TestCase;
78
use AsyncAws\Lambda\Result\AddLayerVersionPermissionResponse;
@@ -18,7 +19,7 @@ public function testAddLayerVersionPermissionResponse(): void
1819
}');
1920

2021
$client = new MockHttpClient($response);
21-
$result = new AddLayerVersionPermissionResponse($client->request('POST', 'http://localhost'), $client);
22+
$result = new AddLayerVersionPermissionResponse(new Response($client->request('POST', 'http://localhost'), $client));
2223

2324
self::assertSame('fooBar', $result->getStatement());
2425
self::assertSame('123456', $result->getRevisionId());

tests/Unit/Result/InvocationResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\Lambda\Tests\Unit\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
67
use AsyncAws\Lambda\Result\InvocationResponse;
78
use PHPUnit\Framework\TestCase;
@@ -16,7 +17,7 @@ public function testInvocationResponse(): void
1617
$response = new SimpleMockedResponse($json, ['content-type' => 'application/json'], 200);
1718

1819
$client = new MockHttpClient($response);
19-
$result = new InvocationResponse($client->request('POST', 'http://localhost'), $client);
20+
$result = new InvocationResponse(new Response($client->request('POST', 'http://localhost'), $client));
2021

2122
self::assertEquals($json, $result->getPayload());
2223
self::assertEquals(200, $result->getStatusCode());

tests/Unit/Result/ListLayerVersionsResponseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace AsyncAws\Lambda\Tests\Unit\Result;
44

5+
use AsyncAws\Core\Response;
56
use AsyncAws\Core\Test\Http\SimpleMockedResponse;
67
use AsyncAws\Core\Test\TestCase;
78
use AsyncAws\Lambda\Result\LayerVersionsListItem;
@@ -32,7 +33,7 @@ public function testListLayerVersionsResponse(): void
3233
$response = new SimpleMockedResponse(json_encode($data));
3334

3435
$client = new MockHttpClient($response);
35-
$result = new ListLayerVersionsResponse($client->request('POST', 'http://localhost'), $client);
36+
$result = new ListLayerVersionsResponse(new Response($client->request('POST', 'http://localhost'), $client));
3637

3738
self::assertEquals($nextMarker, $result->getNextMarker());
3839
/** @var LayerVersionsListItem $version */

0 commit comments

Comments
 (0)