Skip to content

Commit de8988a

Browse files
author
MattiasWiesner
committed
dont use namespace
1 parent 5d12b7d commit de8988a

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@
1616
}
1717
],
1818
"autoload": {
19-
"psr-0": { "CloudControl": "" }
19+
"files": ['phpcclib.php']
2020
}
2121
}

phpcclib.php

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
2-
namespace CloudControl;
3-
42
/**
5-
* require Pear::\HTTP_Request2
3+
* require Pear::HTTP_Request2
64
*/
75
require_once 'HTTP/Request2.php';
86

@@ -1182,7 +1180,7 @@ private function _jsonDecode($content) {
11821180
* base cloudControl api exception
11831181
*/
11841182

1185-
class CCException extends \Exception {
1183+
class CCException extends Exception {
11861184
}
11871185

11881186
/*
@@ -1351,7 +1349,7 @@ public function setAuth($email, $password) {
13511349
* @return string json encoded servers response
13521350
*/
13531351
public function post($resource, $data) {
1354-
return $this->_request($resource, \HTTP_Request2::METHOD_POST, $data);
1352+
return $this->_request($resource, HTTP_Request2::METHOD_POST, $data);
13551353
}
13561354

13571355
/**
@@ -1371,7 +1369,7 @@ public function post($resource, $data) {
13711369
* @return string json encoded servers response
13721370
*/
13731371
public function get($resource, $data=array()) {
1374-
return $this->_request($resource, \HTTP_Request2::METHOD_GET, $data);
1372+
return $this->_request($resource, HTTP_Request2::METHOD_GET, $data);
13751373
}
13761374

13771375
/**
@@ -1392,7 +1390,7 @@ public function get($resource, $data=array()) {
13921390
* @return string json encoded servers response
13931391
*/
13941392
public function put($resource, $data) {
1395-
return $this->_request($resource, \HTTP_Request2::METHOD_PUT, $data);
1393+
return $this->_request($resource, HTTP_Request2::METHOD_PUT, $data);
13961394
}
13971395

13981396
/**
@@ -1412,11 +1410,11 @@ public function put($resource, $data) {
14121410
* @return string json encoded servers response
14131411
*/
14141412
public function delete($resource) {
1415-
return $this->_request($resource, \HTTP_Request2::METHOD_DELETE);
1413+
return $this->_request($resource, HTTP_Request2::METHOD_DELETE);
14161414
}
14171415

14181416
/**
1419-
* we use the Pear::\HTTP_Request2 for all the heavy HTTP protocol lifting.
1417+
* we use the Pear::HTTP_Request2 for all the heavy HTTP protocol lifting.
14201418
*
14211419
* @param string $resource api-resource
14221420
* @param string $method request method [default:"GET"]
@@ -1436,20 +1434,20 @@ public function delete($resource) {
14361434
*
14371435
* @return string json encoded servers response
14381436
*/
1439-
private function _request($resource, $method=\HTTP_Request2::METHOD_GET, $data=array(), $headers=array()) {
1437+
private function _request($resource, $method=HTTP_Request2::METHOD_GET, $data=array(), $headers=array()) {
14401438
$url = $this->_url . $resource;
1441-
$request = new \HTTP_Request2($url);
1439+
$request = new HTTP_Request2($url);
14421440
$request->setConfig('ssl_verify_peer', API::SSL_VERIFY_PEER);
14431441

14441442
$methods = array(
1445-
'options' => \HTTP_Request2::METHOD_OPTIONS,
1446-
'get' => \HTTP_Request2::METHOD_GET,
1447-
'head' => \HTTP_Request2::METHOD_HEAD,
1448-
'post' => \HTTP_Request2::METHOD_POST,
1449-
'put' => \HTTP_Request2::METHOD_PUT,
1450-
'delete' => \HTTP_Request2::METHOD_DELETE,
1451-
'trace' => \HTTP_Request2::METHOD_TRACE,
1452-
'connect' => \HTTP_Request2::METHOD_CONNECT
1443+
'options' => HTTP_Request2::METHOD_OPTIONS,
1444+
'get' => HTTP_Request2::METHOD_GET,
1445+
'head' => HTTP_Request2::METHOD_HEAD,
1446+
'post' => HTTP_Request2::METHOD_POST,
1447+
'put' => HTTP_Request2::METHOD_PUT,
1448+
'delete' => HTTP_Request2::METHOD_DELETE,
1449+
'trace' => HTTP_Request2::METHOD_TRACE,
1450+
'connect' => HTTP_Request2::METHOD_CONNECT
14531451
);
14541452
$request->setMethod($methods[strtolower($method)]);
14551453

@@ -1465,15 +1463,15 @@ private function _request($resource, $method=\HTTP_Request2::METHOD_GET, $data=a
14651463
if ($this->_token) {
14661464
$headers['Authorization'] = sprintf('cc_auth_token="%s"', $this->_token);
14671465
} else if ($this->_email && $this->_password) {
1468-
$request->setAuth($this->_email, $this->_password, \HTTP_Request2::AUTH_BASIC);
1466+
$request->setAuth($this->_email, $this->_password, HTTP_Request2::AUTH_BASIC);
14691467
}
14701468

14711469
#
14721470
# The API expects the body to be urlencoded. If data was passed to
14731471
# the request method we therefore use urlencode from urllib.
14741472
#
14751473
if (!empty($data)) {
1476-
if ($request->getMethod() == \HTTP_Request2::METHOD_GET) {
1474+
if ($request->getMethod() == HTTP_Request2::METHOD_GET) {
14771475
$url = $request->getUrl();
14781476
$url->setQueryVariables($data);
14791477
} else {
@@ -1512,7 +1510,7 @@ private function _request($resource, $method=\HTTP_Request2::METHOD_GET, $data=a
15121510
$response = $request->send();
15131511
return $this->_return($response);
15141512
}
1515-
catch (\HTTP_Request2_Exception $e) {
1513+
catch (HTTP_Request2_Exception $e) {
15161514
# if we could not reach the API we wait 1s and try again
15171515
sleep(1);
15181516
# if we tried for the fifth time we give up - and cry a little
@@ -1526,7 +1524,7 @@ private function _request($resource, $method=\HTTP_Request2::METHOD_GET, $data=a
15261524
/**
15271525
* evaluate response object
15281526
*
1529-
* @param \HTTP_Request2_Response $resp
1527+
* @param HTTP_Request2_Response $resp
15301528
*
15311529
* @throws BadRequestError
15321530
* @throws UnauthorizedError

0 commit comments

Comments
 (0)