Skip to content

Commit d59ca91

Browse files
committed
Follow PSR2 standards
1 parent 10a5624 commit d59ca91

12 files changed

+56
-68
lines changed

.scrutinizer.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ build:
1212
checks:
1313
php:
1414
custom_coding_standard:
15-
ruleset_path: 'ruleset.xml'
15+
ruleset_path: 'phpcs.xml'

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ before_script:
2222

2323
script:
2424
- phpunit --coverage-clover build/logs/clover.xml ./Tests
25-
- vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=ruleset.xml QuickPay
25+
- vendor/bin/phpcs --runtime-set ignore_warnings_on_exit 1 --standard=phpcs.xml QuickPay
2626

2727
after_script:
2828
- php vendor/bin/coveralls -v

QuickPay/API/Client.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* @class QuickPay_Client
6-
* @since 1.0.0
6+
* @since 0.1.0
77
* @package QuickPay
88
* @category Class
99
* @author Patrick Tolvstein, Perfect Solution ApS

QuickPay/API/Constants.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/**
55
* @class QuickPay_Constants
6-
* @since 1.0.0
6+
* @since 0.1.0
77
* @package QuickPay
88
* @category Class
99
* @author Patrick Tolvstein, Perfect Solution ApS

QuickPay/API/Exception.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/**
55
* @class QuickPay_Exception
66
* @extends Exception
7-
* @since 1.0.0
7+
* @since 0.1.0
88
* @package QuickPay
99
* @category Class
1010
* @author Patrick Tolvstein, Perfect Solution ApS

QuickPay/API/Request.php

+14-14
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
use QuickPay\API\Response;
66

77
/**
8-
* @class QuickPay_Request
9-
* @since 1.0.0
10-
* @package QuickPay
11-
* @category Class
12-
* @author Patrick Tolvstein, Perfect Solution ApS
13-
* @docs http://tech.quickpay.net/api/
8+
* @class QuickPay_Request
9+
* @since 0.1.0
10+
* @package QuickPay
11+
* @category Class
12+
* @author Patrick Tolvstein, Perfect Solution ApS
13+
* @docs http://tech.quickpay.net/api/
1414
*/
1515
class Request
1616
{
@@ -55,7 +55,7 @@ public function get($path, $query = array())
5555
}
5656

5757
// Set the request params
58-
$this->set_url($path);
58+
$this->setUrl($path);
5959

6060
// Start the request and return the response
6161
return $this->execute('GET');
@@ -72,7 +72,7 @@ public function get($path, $query = array())
7272
public function post($path, $form = array())
7373
{
7474
// Set the request params
75-
$this->set_url($path);
75+
$this->setUrl($path);
7676

7777
// Start the request and return the response
7878
return $this->execute('POST', $form);
@@ -89,7 +89,7 @@ public function post($path, $form = array())
8989
public function put($path, $form = array())
9090
{
9191
// Set the request params
92-
$this->set_url($path);
92+
$this->setUrl($path);
9393

9494
// Start the request and return the response
9595
return $this->execute('PUT', $form);
@@ -106,7 +106,7 @@ public function put($path, $form = array())
106106
public function patch($path, $form = array())
107107
{
108108
// Set the request params
109-
$this->set_url($path);
109+
$this->setUrl($path);
110110

111111
// Start the request and return the response
112112
return $this->execute('PATCH', $form);
@@ -123,21 +123,21 @@ public function patch($path, $form = array())
123123
public function delete($path, $form = array())
124124
{
125125
// Set the request params
126-
$this->set_url($path);
126+
$this->setUrl($path);
127127

128128
// Start the request and return the response
129129
return $this->execute('DELETE', $form);
130130
}
131131

132132
/**
133-
* set_url function.
133+
* setUrl function.
134134
*
135135
* Takes an API request string and appends it to the API url
136136
*
137137
* @access protected
138138
* @return void
139139
*/
140-
protected function set_url($params)
140+
protected function setUrl($params)
141141
{
142142
curl_setopt($this->client->ch, CURLOPT_URL, Constants::API_URL . trim($params, '/'));
143143
}
@@ -171,7 +171,7 @@ protected function execute($request_type, $form = array())
171171
$response_data = curl_exec($this->client->ch);
172172

173173
if (curl_errno($this->client->ch) !== 0) {
174-
//An error occurred
174+
// An error occurred
175175
fclose($fh_header);
176176
throw new Exception(curl_error($this->client->ch), curl_errno($this->client->ch));
177177
}

QuickPay/API/Response.php

+19-18
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
namespace QuickPay\API;
33

44
/**
5-
* @class QuickPay_Response
6-
* @since 1.0.0
7-
* @package QuickPay
8-
* @category Class
9-
* @author Patrick Tolvstein, Perfect Solution ApS
10-
* @docs http://tech.quickpay.net/api/
5+
* @class QuickPay_Response
6+
* @since 0.1.0
7+
* @package QuickPay
8+
* @category Class
9+
* @author Patrick Tolvstein, Perfect Solution ApS
10+
* @docs http://tech.quickpay.net/api/
1111
*/
1212
class Response
1313
{
@@ -58,15 +58,16 @@ public function __construct($status_code, $sent_headers, $received_headers, $res
5858
}
5959

6060
/**
61-
* as_raw
61+
* asRaw
6262
*
6363
* Returns the HTTP status code, headers and response body.
6464
* Usage: list($status_code, $headers, $response_body) = $response->as_raw().
6565
*
66-
* @param boolan $keep_authorization_value Normally the value of the Authorization: header is masked. True keeps the sent value.
67-
* @return array [integer, string[], string]
66+
* @param boolan $keep_authorization_value Normally the value of the
67+
* Authorization: header is masked. True keeps the sent value.
68+
* @return array [integer, string[], string]
6869
*/
69-
public function as_raw($keep_authorization_value = false)
70+
public function asRaw($keep_authorization_value = false)
7071
{
7172
// To avoid unintentional logging of credentials the default is to mask the value of the Authorization: header
7273
if ($keep_authorization_value) {
@@ -93,13 +94,13 @@ public function as_raw($keep_authorization_value = false)
9394
}
9495

9596
/**
96-
* as_array
97+
* asArray
9798
*
9899
* Returns the response body as an array
99100
*
100101
* @return array
101102
*/
102-
public function as_array()
103+
public function asArray()
103104
{
104105
if ($response = json_decode($this->response_data, true)) {
105106
return $response;
@@ -109,13 +110,13 @@ public function as_array()
109110
}
110111

111112
/**
112-
* as_object
113+
* asObject
113114
*
114115
* Returns the response body as an array
115116
*
116117
* @return \stdClass
117118
*/
118-
public function as_object()
119+
public function asObject()
119120
{
120121
if ($response = json_decode($this->response_data)) {
121122
return $response;
@@ -125,25 +126,25 @@ public function as_object()
125126
}
126127

127128
/**
128-
* http_status
129+
* httpStatus
129130
*
130131
* Returns the http_status code
131132
*
132133
* @return int
133134
*/
134-
public function http_status()
135+
public function httpStatus()
135136
{
136137
return $this->status_code;
137138
}
138139

139140
/**
140-
* is_success
141+
* isSuccess
141142
*
142143
* Checks if the http status code indicates a succesful or an error response.
143144
*
144145
* @return boolean
145146
*/
146-
public function is_success()
147+
public function isSuccess()
147148
{
148149
if ($this->status_code > 299) {
149150
return false;

QuickPay/QuickPay.php

-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
<?php
22
namespace QuickPay;
33

4-
require_once 'API/Constants.php';
5-
require_once 'API/Exception.php';
6-
require_once 'API/Client.php';
7-
require_once 'API/Request.php';
8-
require_once 'API/Response.php';
9-
104
use QuickPay\API\Client;
115
use QuickPay\API\Request;
126

@@ -19,7 +13,6 @@ class QuickPay
1913
**/
2014
public $request;
2115

22-
2316
/**
2417
* __construct function.
2518
*

README.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -102,27 +102,27 @@ Getting the `HTTP status code`:
102102

103103
```php5
104104
$response = $client->request->get('/payments');
105-
$status = $response->http_status();
105+
$status = $response->httpStatus();
106106

107107
if ($status == 200) {
108108
// Successful request
109109
}
110110
```
111111

112-
The returned response object supports 3 different ways of returning the response body, `as_raw()`, `as_object`, `as_array()`.
112+
The returned response object supports 3 different ways of returning the response body, `asRaw()`, `asObject`, `asArray()`.
113113

114114
```php5
115115
// Get the HTTP status code, headers and raw response body.
116-
list($status_code, $headers, $response_body) = $client->request->get('/payments')->as_raw();
116+
list($status_code, $headers, $response_body) = $client->request->get('/payments')->asRaw();
117117

118118
// Get the response body as an object
119-
$response_body = $client->request->get('/payments')->as_object();
119+
$response_body = $client->request->get('/payments')->asObject();
120120

121121
// Get the response body as an array
122-
$response_body = $client->request->get('/payments')->as_array();
122+
$response_body = $client->request->get('/payments')->asArray();
123123

124124
// Example usage
125-
$payments = $client->request->get('/payments')->as_array();
125+
$payments = $client->request->get('/payments')->asArray();
126126

127127
foreach($payments as $payment) {
128128
//...

Tests/api/RequestTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,34 +30,34 @@ public function testBadAuthentication()
3030

3131
$response = $request->get('/ping');
3232

33-
$this->assertEquals(401, $response->http_status());
33+
$this->assertEquals(401, $response->httpStatus());
3434
}
3535

3636
public function testSuccessfulGetResponse()
3737
{
3838
$pingResponse = $this->request->get('/ping');
3939

40-
$this->assertTrue($pingResponse->is_success());
40+
$this->assertTrue($pingResponse->isSuccess());
4141
}
4242

4343
public function testFailedGetResponse()
4444
{
4545
$pingResponse = $this->request->get('/foobar');
4646

47-
$this->assertFalse($pingResponse->is_success());
47+
$this->assertFalse($pingResponse->isSuccess());
4848
}
4949

5050
public function testSuccesfulPostResponse()
5151
{
5252
$pingResponse = $this->request->post('/ping');
5353

54-
$this->assertTrue($pingResponse->is_success());
54+
$this->assertTrue($pingResponse->isSuccess());
5555
}
5656

5757
public function testFailedPostResponse()
5858
{
5959
$pingResponse = $this->request->post('/foobar');
6060

61-
$this->assertFalse($pingResponse->is_success());
61+
$this->assertFalse($pingResponse->isSuccess());
6262
}
6363
}

Tests/api/ResponseTest.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public function testSuccessResponseHTTPCodes($httpCode, $expectedResult)
2020
{
2121
$response = new Response($httpCode, '', '', '');
2222

23-
$result = $response->is_success();
23+
$result = $response->isSuccess();
2424

2525
$this->assertEquals($result, $expectedResult);
2626
}
@@ -48,7 +48,7 @@ public function testReturnOfHTTPStatusCodes($httpCode, $expectedCode)
4848
{
4949
$response = new Response($httpCode, '', '', '');
5050

51-
$statusCode = $response->http_status();
51+
$statusCode = $response->httpStatus();
5252

5353
$this->assertEquals($statusCode, $expectedCode);
5454
}
@@ -66,7 +66,7 @@ public function testReturnOfResponseDataAsArray()
6666
{
6767
$response = new Response(200, '', '', $this->responseTestData);
6868

69-
$responseArray = $response->as_array();
69+
$responseArray = $response->asArray();
7070

7171
$this->assertTrue(is_array($responseArray));
7272
}
@@ -75,7 +75,7 @@ public function testReturnOfEmptyResponseDataAsArray()
7575
{
7676
$response = new Response(200, '', '', '');
7777

78-
$responseArray = $response->as_array();
78+
$responseArray = $response->asArray();
7979

8080
$this->assertTrue(is_array($responseArray));
8181
}
@@ -84,7 +84,7 @@ public function testReturnOfResponseDataAsObject()
8484
{
8585
$response = new Response(200, '', '', $this->responseTestData);
8686

87-
$responseObject = $response->as_object();
87+
$responseObject = $response->asObject();
8888

8989
$this->assertTrue(is_object($responseObject));
9090
}
@@ -93,7 +93,7 @@ public function testReturnOfEmptyResponseDataAsObject()
9393
{
9494
$response = new Response(200, '', '', '');
9595

96-
$responseObject = $response->as_object();
96+
$responseObject = $response->asObject();
9797

9898
$this->assertTrue(is_object($responseObject));
9999
}
@@ -102,7 +102,7 @@ public function testReturnOfResponseDataAsRaw()
102102
{
103103
$response = new Response(200, '', '', $this->responseTestData);
104104

105-
list($statusCode, $headers, $responseRaw) = $response->as_raw();
105+
list($statusCode, $headers, $responseRaw) = $response->asRaw();
106106

107107
$this->assertTrue(is_int($statusCode));
108108
$this->assertTrue(is_array($headers));

0 commit comments

Comments
 (0)