Skip to content

Commit 73cacd1

Browse files
committed
setCustomHeaders takes a string rather than an array
1 parent f889d20 commit 73cacd1

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

examples/language.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,8 @@
1818
$params = new DocumentParameters();
1919
$content = $language_data;
2020
$params->set('content', $content);
21-
$appHeader = [];
22-
$appHeader = "X-RosetteAPI-App: php-app";
23-
$customHeaders = [];
24-
$customHeaders[0] = $appHeader;
25-
$api->setCustomHeaders($customHeaders);
21+
$customHeader = "X-RosetteAPI-App: php-app";
22+
$api->setCustomHeaders($customHeader);
2623

2724
try {
2825
$result = $api->language($params);

source/rosette/api/Api.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -326,16 +326,14 @@ public function getCustomHeaders()
326326
* @param array $headers
327327
*
328328
*/
329-
public function setCustomHeaders($headers)
329+
public function setCustomHeaders($header)
330330
{
331331
$this->clearCustomHeaders();
332-
if($headers != null){
333-
foreach ($headers as $key => $value) {
334-
if(preg_match("/^X-RosetteAPI-/", $value)){
335-
array_push($this->customHeaders, $value);
336-
} else {
337-
throw new RosetteException("Custom headers must start with \"X-\"");
338-
}
332+
if($header != null){
333+
if(preg_match("/^X-RosetteAPI-/", $header)){
334+
array_push($this->customHeaders, $header);
335+
} else {
336+
throw new RosetteException("Custom headers must start with \"X-\"");
339337
}
340338
}
341339
}

spec/rosette/api/ApiSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,12 +275,12 @@ public function it_fails_with_non_200_response($params, $request)
275275

276276
public function it_fails_with_incorrectly_formatted_custom_header($params, $request)
277277
{
278-
$this->shouldThrow('rosette\api\RosetteException')->duringSetCustomHeaders(array("test"));
278+
$this->shouldThrow('rosette\api\RosetteException')->duringSetCustomHeaders("test");
279279
}
280280

281281
public function it_sets_gets_clears_customHeaders()
282282
{
283-
$this->setCustomHeaders(array('X-RosetteAPI-test'));
283+
$this->setCustomHeaders('X-RosetteAPI-test');
284284
$this->getCustomHeaders()->shouldBe(array('X-RosetteAPI-test'));
285285
$this->clearCustomHeaders();
286286
$this->getCustomHeaders()->shouldBe(array());

0 commit comments

Comments
 (0)