Skip to content

Commit f7b829e

Browse files
committed
fixes #100
1 parent 02b118e commit f7b829e

File tree

2 files changed

+51
-43
lines changed

2 files changed

+51
-43
lines changed

lib/OpenCloud/AbstractClass/Service.php

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@
2626
*
2727
* @author Glen Campbell <[email protected]>
2828
*/
29-
abstract class Service extends \OpenCloud\Base\Base
29+
abstract class Service extends \OpenCloud\Base\Base
3030
{
3131

3232
private $conn;
3333
private $service_type;
3434
private $service_name;
35-
private $service_region;
35+
private $service_region;
3636
private $service_url;
37-
37+
3838
protected $_namespaces = array();
3939

4040
/**
@@ -54,10 +54,10 @@ abstract class Service extends \OpenCloud\Base\Base
5454
* (e.g., "publicURL")
5555
*/
5656
public function __construct(
57-
OpenStack $conn,
58-
$type,
59-
$name,
60-
$region,
57+
OpenStack $conn,
58+
$type,
59+
$name,
60+
$region,
6161
$urltype = RAXSDK_URL_PUBLIC
6262
) {
6363
$this->conn = $conn;
@@ -77,11 +77,11 @@ public function __construct(
7777
public function Url($resource = '', array $param = array())
7878
{
7979
$baseurl = $this->service_url;
80-
80+
8181
if ($resource) {
8282
$baseurl = Lang::noslash($baseurl).'/'.$resource;
8383
}
84-
84+
8585
if (!empty($param)) {
8686
$baseurl .= '?'.$this->MakeQueryString($param);
8787
}
@@ -95,7 +95,7 @@ public function Url($resource = '', array $param = array())
9595
* @api
9696
* @return array of objects
9797
*/
98-
public function Extensions()
98+
public function Extensions()
9999
{
100100
$ext = $this->GetMetaUrl('extensions');
101101

@@ -112,10 +112,10 @@ public function Extensions()
112112
* @api
113113
* @return array of limits
114114
*/
115-
public function Limits()
115+
public function Limits()
116116
{
117117
$lim = $this->GetMetaUrl('limits');
118-
118+
119119
if (is_object($lim)) {
120120
return $lim->limits;
121121
} else {
@@ -137,10 +137,14 @@ public function Limits()
137137
* @param string $body An optional body for POST/PUT requests
138138
* @return \OpenCloud\HttpResult
139139
*/
140-
public function Request($url, $method = 'GET', array $headers = array() ,$body = null)
140+
public function Request(
141+
$url,
142+
$method = 'GET',
143+
array $headers = array(),
144+
$body = null)
141145
{
142146
$headers['X-Auth-Token'] = $this->conn->Token();
143-
147+
144148
if ($tenant = $this->conn->Tenant()) {
145149
$headers['X-Auth-Project-Id'] = $tenant;
146150
}
@@ -158,7 +162,7 @@ public function Request($url, $method = 'GET', array $headers = array() ,$body =
158162
* query strings
159163
* @return \OpenCloud\Collection
160164
*/
161-
public function Collection($class, $url = null, $parent = null, array $parm = array())
165+
public function Collection($class, $url = null, $parent = null, array $parm = array())
162166
{
163167
// set the element name
164168
$collection = $class::JsonCollectionName();
@@ -229,7 +233,7 @@ public function Collection($class, $url = null, $parent = null, array $parm = ar
229233
} elseif (isset($obj->$collection)) {
230234
if (!$element) {
231235
$coll_obj = new Collection($parent, $class, $obj->$collection);
232-
} else {
236+
} else {
233237
// handle element levels
234238
$arr = array();
235239
foreach($obj->$collection as $index => $item) {
@@ -256,7 +260,7 @@ public function Collection($class, $url = null, $parent = null, array $parm = ar
256260
* @api
257261
* @return string
258262
*/
259-
public function Region()
263+
public function Region()
260264
{
261265
return $this->service_region;
262266
}
@@ -269,7 +273,7 @@ public function Region()
269273
* @api
270274
* @return string
271275
*/
272-
public function Name()
276+
public function Name()
273277
{
274278
return $this->service_name;
275279
}
@@ -279,7 +283,7 @@ public function Name()
279283
*
280284
* @return array
281285
*/
282-
public function namespaces()
286+
public function namespaces()
283287
{
284288
if (!isset($this->_namespaces)) {
285289
return array();
@@ -308,7 +312,7 @@ public function namespaces()
308312
* @param string $urltype The URL type; defaults to "publicURL"
309313
* @return string The URL of the service
310314
*/
311-
private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
315+
private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
312316
{
313317
$found = 0;
314318
$catalog = $this->conn->serviceCatalog();
@@ -354,7 +358,7 @@ private function get_endpoint($type, $name, $region, $urltype = 'publicURL')
354358
* at the beginning or end
355359
* @return \stdClass object
356360
*/
357-
private function GetMetaUrl($resource)
361+
private function GetMetaUrl($resource)
358362
{
359363
$urlbase = $this->get_endpoint(
360364
$this->service_type,
@@ -380,15 +384,15 @@ private function GetMetaUrl($resource)
380384
if ($response->HttpStatus() >= 300) {
381385
throw new Exceptions\HttpError(sprintf(
382386
Lang::translate('Error accessing [%s] - status [%d], response [%s]'),
383-
$urlbase,
384-
$response->HttpStatus(),
387+
$urlbase,
388+
$response->HttpStatus(),
385389
$response->HttpBody()
386390
));
387391
}
388392

389393
// we're good; proceed
390394
$obj = json_decode($response->HttpBody());
391-
395+
392396
if ($this->CheckJsonError()) {
393397
return false;
394398
}

lib/OpenCloud/DNS/Service.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ class Service extends AbstractService
3030
* @param string $urltype the type of URL
3131
*/
3232
public function __construct(
33-
OpenStack $connection,
34-
$serviceName,
35-
$serviceRegion,
33+
OpenStack $connection,
34+
$serviceName,
35+
$serviceRegion,
3636
$urltype
3737
) {
3838
$this->debug(Lang::translate('initializing DNS...'));
@@ -52,7 +52,7 @@ public function __construct(
5252
* @param mixed $info either the ID, an object, or array of parameters
5353
* @return DNS\Domain
5454
*/
55-
public function Domain($info = null)
55+
public function Domain($info = null)
5656
{
5757
return new Domain($this, $info);
5858
}
@@ -64,7 +64,7 @@ public function Domain($info = null)
6464
* @param array $filter key/value pairs to use as query strings
6565
* @return \OpenCloud\Collection
6666
*/
67-
public function DomainList($filter = array())
67+
public function DomainList($filter = array())
6868
{
6969
$url = $this->Url(Domain::ResourceName(), $filter);
7070
return $this->Collection('\OpenCloud\DNS\Domain', $url);
@@ -76,7 +76,7 @@ public function DomainList($filter = array())
7676
* @param mixed $info ID, array, or object containing record data
7777
* @return Record
7878
*/
79-
public function PtrRecord($info = null)
79+
public function PtrRecord($info = null)
8080
{
8181
return new PtrRecord($this, $info);
8282
}
@@ -88,7 +88,7 @@ public function PtrRecord($info = null)
8888
* retrieve the PTR records
8989
* @return Collection
9090
*/
91-
public function PtrRecordList(Server $server)
91+
public function PtrRecordList(Server $server)
9292
{
9393
$service_name = $server->Service()->Name();
9494
$url = $this->Url('rdns/' . $service_name) . '?' . $this->MakeQueryString(array('href' => $server->Url()));
@@ -106,7 +106,11 @@ public function PtrRecordList(Server $server)
106106
* @param string $body the body of the request (for PUT and POST)
107107
* @return \OpenCloud\HttpResponse
108108
*/
109-
public function Request($url, $method = 'GET', $headers = array(), $body = null)
109+
public function Request(
110+
$url,
111+
$method = 'GET',
112+
array $headers = array(),
113+
$body = null)
110114
{
111115
$headers['Accept'] = RAXSDK_CONTENT_TYPE_JSON;
112116
$headers['Content-Type'] = RAXSDK_CONTENT_TYPE_JSON;
@@ -127,7 +131,7 @@ public function Request($url, $method = 'GET', $headers = array(), $body = null)
127131
* @param string $body the body of the request (for PUT and POST)
128132
* @return DNS\AsyncResponse
129133
*/
130-
public function AsyncRequest($url, $method = 'GET', $headers = array(), $body = null)
134+
public function AsyncRequest($url, $method = 'GET', $headers = array(), $body = null)
131135
{
132136
// perform the initial request
133137
$resp = $this->Request($url, $method, $headers, $body);
@@ -136,9 +140,9 @@ public function AsyncRequest($url, $method = 'GET', $headers = array(), $body =
136140
if ($resp->HttpStatus() > 204) {
137141
throw new Exceptions\AsyncHttpError(sprintf(
138142
Lang::translate('Unexpected HTTP status for async request: URL [%s] method [%s] status [%s] response [%s]'),
139-
$url,
140-
$method,
141-
$resp->HttpStatus(),
143+
$url,
144+
$method,
145+
$resp->HttpStatus(),
142146
$resp->HttpBody()
143147
));
144148
}
@@ -162,7 +166,7 @@ public function AsyncRequest($url, $method = 'GET', $headers = array(), $body =
162166
* @param string $data the BIND_9 formatted data to import
163167
* @return DNS\AsyncResponse
164168
*/
165-
public function Import($data)
169+
public function Import($data)
166170
{
167171
// determine the URL
168172
$url = $this->Url('domains/import');
@@ -190,10 +194,10 @@ public function Import($data)
190194
* returns a list of limits
191195
*
192196
*/
193-
public function Limits($type = null)
197+
public function Limits($type = null)
194198
{
195199
$url = $this->url('limits');
196-
200+
197201
if ($type !== null) {
198202
$url .= '/' . $type;
199203
}
@@ -208,7 +212,7 @@ public function Limits($type = null)
208212
*
209213
* @return array
210214
*/
211-
public function LimitTypes()
215+
public function LimitTypes()
212216
{
213217
$object = $this->SimpleRequest($this->Url('limits/types'));
214218
return $object->limitTypes;
@@ -219,7 +223,7 @@ public function LimitTypes()
219223
*
220224
* @param string $url the URL to GET
221225
*/
222-
public function SimpleRequest($url)
226+
public function SimpleRequest($url)
223227
{
224228
// perform the request
225229
$response = $this->Request($url);
@@ -237,9 +241,9 @@ public function SimpleRequest($url)
237241
// decode the JSON
238242
$json = $response->HttpBody();
239243
$this->debug(Lang::translate('Limit Types JSON [%s]'), $json);
240-
244+
241245
$object = json_decode($json);
242-
246+
243247
if ($this->CheckJsonError()) {
244248
return false;
245249
}

0 commit comments

Comments
 (0)