Skip to content

Commit 990b218

Browse files
committed
renamed RequestListener to NormalizeArrayListener and added ashort description for this listener.
1 parent 099ee40 commit 990b218

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

lib/Bitbucket/API/Api.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Bitbucket\API;
1313

14-
use Bitbucket\API\Http\Listener\RequestListener;
14+
use Bitbucket\API\Http\Listener\NormalizeArrayListener;
1515
use Buzz\Message\MessageInterface;
1616
use Buzz\Message\RequestInterface;
1717
use Buzz\Client\ClientInterface as BuzzClientInterface;
@@ -62,7 +62,7 @@ public function __construct(BuzzClientInterface $client = null)
6262
$this->client = (is_null($client)) ? new Curl : $client;
6363
$this->httpClient = new Client(array(), $client);
6464

65-
$this->httpClient->addListener(new RequestListener());
65+
$this->httpClient->addListener(new NormalizeArrayListener());
6666

6767
return $this;
6868
}

lib/Bitbucket/API/Http/Listener/RequestListener.php renamed to lib/Bitbucket/API/Http/Listener/NormalizeArrayListener.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,23 @@
1515
use Buzz\Message\RequestInterface;
1616

1717
/**
18+
* Transform PHP array to API array
19+
*
20+
* PHP array square brackets does not play nice with remote API,
21+
* which expects just the key name, without brackets.
22+
*
23+
* Transforms: foo[0]=xxx&foo[1]=yyy" to "foo=xxx&foo=yyy"
24+
*
1825
* @author Alexandru G. <alex@gentle.ro>
1926
*/
20-
class RequestListener implements ListenerInterface
27+
class NormalizeArrayListener implements ListenerInterface
2128
{
2229
/**
2330
* {@inheritDoc}
2431
*/
2532
public function getName()
2633
{
27-
return 'request';
34+
return 'normalize_array';
2835
}
2936

3037
/**

test/Bitbucket/Tests/API/Http/Listener/RequestListenerTest.php renamed to test/Bitbucket/Tests/API/Http/Listener/NormalizeArrayListenerTest.php

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

33
namespace Bitbucket\Tests\API\Http\Listener;
44

5-
use Bitbucket\API\Http\Listener\RequestListener;
5+
use Bitbucket\API\Http\Listener\NormalizeArrayListener;
66
use Bitbucket\Tests\API as Tests;
77
use Buzz\Message\Request;
88

99
/**
1010
* @author Alexandru G. <alex@gentle.ro>
1111
*/
12-
class RequestListenerTest extends Tests\TestCase
12+
class NormalizeArrayListenerTest extends Tests\TestCase
1313
{
1414
public function testPHPArrayToApiArrayConversion()
1515
{
16-
$listener = new RequestListener();
16+
$listener = new NormalizeArrayListener();
1717
$request = new Request('POST', '/dummy');
1818

1919
$request->setContent(

0 commit comments

Comments
 (0)