Skip to content

Commit 152c9b0

Browse files
committed
Sanity & minor readme updates.
1 parent c813e1d commit 152c9b0

File tree

5 files changed

+51
-4
lines changed

5 files changed

+51
-4
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ PHP client implementation for the Consul API
44

55
The primary purpose of this lib is to provide a dependency-free way of interacting with [Consul](https://www.consul.io/).
66

7-
It is in alpha stages of development. Currently the only thing it can do is query KV data.
7+
It is in alpha stages of development.
88

99
This library is loosely based upon the [official GO client](https://github.com/hashicorp/consul/tree/master/api).
1010

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
],
1313

1414
"keywords": [
15-
"consul"
15+
"consul",
16+
"consul-api"
1617
],
1718

1819
"require": {

src/AbstractConsulClient.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,15 @@ protected function requireOK(array $requestResult)
5454
return $requestResult;
5555

5656
if (200 !== $response->httpCode)
57+
{
5758
return [$duration, $response, new Error('warn', sprintf(
5859
'%s - Error seen while executing "%s". Response code: %d. Message: %s',
5960
get_class($this),
6061
$response->url,
6162
$response->httpCode,
6263
$response->curlError
6364
))];
65+
}
6466

6567
return [$duration, $response, null];
6668
}

src/HttpResponse.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ public function __construct($response, array $curlInfo, $curlError)
123123
$this->localPort = $curlInfo['local_port'];
124124
$this->requestHeader = $curlInfo['request_header'];
125125

126-
127126
$this->curlError = $curlError;
128127

129128
if (is_string($response))
@@ -133,10 +132,12 @@ public function __construct($response, array $curlInfo, $curlError)
133132
/**
134133
* @return array
135134
*/
136-
public function parseRequestHeaders()
135+
public function getRequestHeaderArray()
137136
{
138137
if (null === $this->_requestHeaderArray)
139138
{
139+
$this->_requestHeaderArray = array();
140+
140141
foreach(explode("\r\n", $this->requestHeader) as $header)
141142
{
142143
if ('' === $header)

src/Params.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,47 @@ public function set($param, $value)
3434
$this[$param] = $value;
3535
return $this;
3636
}
37+
38+
/**
39+
* Offset to set
40+
* @link http://php.net/manual/en/arrayaccess.offsetset.php
41+
* @param mixed $offset The offset to assign the value to.
42+
* @param mixed $value The value to set.
43+
* @return void
44+
*/
45+
public function offsetSet($offset, $value)
46+
{
47+
if (is_string($offset))
48+
{
49+
switch(strtolower($offset))
50+
{
51+
case 'datacenter':
52+
case 'dc':
53+
$offset = 'Datacenter';
54+
break;
55+
56+
case 'allowstale':
57+
case 'stale':
58+
$offset = 'AllowStale';
59+
break;
60+
61+
case 'requireconsistent':
62+
case 'consistent':
63+
$offset = 'RequireConsistent';
64+
break;
65+
66+
case 'waitindex':
67+
case 'index':
68+
$offset = 'WaitIndex';
69+
break;
70+
71+
case 'waittime':
72+
case 'wait':
73+
$offset = 'WaitTime';
74+
break;
75+
}
76+
}
77+
78+
parent::offsetSet($offset, $value);
79+
}
3780
}

0 commit comments

Comments
 (0)