Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd74d28

Browse filesBrowse files
author
Yukihiro Arisawa
committed
add AmazonSqsQueryStringParser class
1 parent 3792db7 commit fd74d28
Copy full SHA for fd74d28

File tree

Expand file treeCollapse file tree

3 files changed

+73
-4
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+73
-4
lines changed
+37Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Tests\Transport;
13+
14+
use PHPUnit\Framework\TestCase;
15+
use Symfony\Component\Messenger\Bridge\AmazonSqs\Transport\AmazonSqsQueryStringParser;
16+
17+
class AmazonSqsQueryStringParserTest extends TestCase
18+
{
19+
public function testParse()
20+
{
21+
$queryStrings = 'access_key=1&secret_key=A+a+B+b&region=[\^$.|?*+-*${}/?!"%()&queue_name=';
22+
23+
$SUT = $this->getSUT();
24+
$actual = $SUT->parse($queryStrings);
25+
26+
$this->assertCount(4, $actual);
27+
$this->assertSame('1', $actual['access_key']);
28+
$this->assertSame('A+a+B+b', $actual['secret_key']);
29+
$this->assertSame('[\^$.|?*+-*${}/?!"%()', $actual['region']);
30+
$this->assertSame('', $actual['queue_name']);
31+
}
32+
33+
private function getSUT()
34+
{
35+
return new AmazonSqsQueryStringParser();
36+
}
37+
}
+35Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Messenger\Bridge\AmazonSqs\Transport;
13+
14+
/**
15+
* @author Yukihiro Arisawa <goreboothero@gmail.com>
16+
*/
17+
class AmazonSqsQueryStringParser
18+
{
19+
public function parse(string $queryString): array
20+
{
21+
$query = [];
22+
23+
foreach (explode('&', $queryString) as $targetQueryString) {
24+
$queryStringArray = explode('=', $targetQueryString);
25+
$key = $queryStringArray[0] ?? '';
26+
$value = $queryStringArray[1] ?? '';
27+
28+
if ($key !== '') {
29+
$query[$key] = $value;
30+
}
31+
}
32+
33+
return $query;
34+
}
35+
}

‎src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/Connection.php
+1-4Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ public static function fromDsn(string $dsn, array $options = [], HttpClientInter
110110

111111
$query = [];
112112
if (isset($parsedUrl['query'])) {
113-
foreach (explode('&', $parsedUrl['query']) as $queryParameter) {
114-
$queryParameterArray = explode('=', $queryParameter);
115-
$query[$queryParameterArray[0]] = $queryParameterArray[1];
116-
}
113+
$query = (new AmazonSqsQueryStringParser())->parse($parsedUrl['query']);
117114
}
118115

119116
// check for extra keys in options

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.