Completed
Push — master ( bc3bf5...3f770a )
by smiley
02:50
created
src/Traits/RequestTrait.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  * Trait RequestTrait
20 20
  */
21
-trait RequestTrait{
21
+trait RequestTrait {
22 22
 
23 23
 	/**
24 24
 	 * Path to the CA cert file
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 	 * @return \chillerlan\TinyCurl\Response\ResponseInterface
39 39
 	 * @throws \chillerlan\TinyCurl\RequestException
40 40
 	 */
41
-	protected function fetch($url, array $params = [], array $curl_options = []){
41
+	protected function fetch($url, array $params = [], array $curl_options = []) {
42 42
 		$requestOptions               = new RequestOptions;
43 43
 		$requestOptions->curl_options = $curl_options;
44 44
 		$requestOptions->ca_info      = $this->ca_info;
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @return $this
55 55
 	 */
56
-	protected function setRequestCA($ca_info){
56
+	protected function setRequestCA($ca_info) {
57 57
 		$this->ca_info = $ca_info;
58 58
 
59 59
 		return $this;
Please login to merge, or discard this patch.
src/URL.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @property array  params
26 26
  * @property array  parsedquery
27 27
  */
28
-class URL{
28
+class URL {
29 29
 
30 30
 	/**
31 31
 	 * @var string
@@ -84,23 +84,23 @@  discard block
 block discarded – undo
84 84
 	 * @param array  $params
85 85
 	 * @param string $method
86 86
 	 */
87
-	public function __construct($url, array $params = [], $method = 'GET'){
87
+	public function __construct($url, array $params = [], $method = 'GET') {
88 88
 		$this->url    = $url;
89 89
 		$this->params = $params;
90 90
 
91
-		if(in_array(strtoupper($method), ['GET', 'POST'])){
91
+		if (in_array(strtoupper($method), ['GET', 'POST'])) {
92 92
 			$this->method = $method;
93 93
 		}
94 94
 
95 95
 		$url = parse_url($url);
96
-		$this->host      = !isset($url['host'])      ? null : $url['host'];
97
-		$this->port      = !isset($url['port'])      ? null : $url['port'];
98
-		$this->path      = !isset($url['path'])      ? null : $url['path'];
99
-		$this->scheme    = !isset($url['scheme'])    ? null : $url['scheme'];
100
-		$this->query     = !isset($url['query'])     ? null : $url['query'];
101
-		$this->fragment  = !isset($url['fragment'])  ? null : $url['fragment'];
102
-
103
-		if($this->query){
96
+		$this->host      = !isset($url['host']) ? null : $url['host'];
97
+		$this->port      = !isset($url['port']) ? null : $url['port'];
98
+		$this->path      = !isset($url['path']) ? null : $url['path'];
99
+		$this->scheme    = !isset($url['scheme']) ? null : $url['scheme'];
100
+		$this->query     = !isset($url['query']) ? null : $url['query'];
101
+		$this->fragment  = !isset($url['fragment']) ? null : $url['fragment'];
102
+
103
+		if ($this->query) {
104 104
 			parse_str($this->query, $this->parsedquery);
105 105
 		}
106 106
 
@@ -111,21 +111,21 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @return mixed
113 113
 	 */
114
-	public function __get($name){
114
+	public function __get($name) {
115 115
 		return $this->{$name};
116 116
 	}
117 117
 
118 118
 	/**
119 119
 	 * @return string
120 120
 	 */
121
-	public function __toString(){
121
+	public function __toString() {
122 122
 		return $this->mergeParams();
123 123
 	}
124 124
 
125 125
 	/**
126 126
 	 * @return string
127 127
 	 */
128
-	public function overrideParams(){
128
+	public function overrideParams() {
129 129
 		$url  = $this->getURL();
130 130
 		$url .= '?'.http_build_query($this->params);
131 131
 
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	/**
136 136
 	 * @return string
137 137
 	 */
138
-	public function mergeParams(){
138
+	public function mergeParams() {
139 139
 		$url  = $this->getURL();
140 140
 		$url .= '?'.http_build_query(array_merge($this->parsedquery, $this->params));
141 141
 
@@ -145,23 +145,23 @@  discard block
 block discarded – undo
145 145
 	/**
146 146
 	 * @return string
147 147
 	 */
148
-	protected function getURL(){
148
+	protected function getURL() {
149 149
 		$url = '';
150 150
 
151
-		if($this->scheme){
151
+		if ($this->scheme) {
152 152
 			$url .= $this->scheme.':';
153 153
 		}
154 154
 
155
-		if($this->host){
155
+		if ($this->host) {
156 156
 			$url .= '//'.$this->host;
157 157
 
158
-			if($this->port){
158
+			if ($this->port) {
159 159
 				$url .= ':'.$this->port;
160 160
 			}
161 161
 
162 162
 		}
163 163
 
164
-		if($this->path){
164
+		if ($this->path) {
165 165
 			$url .= $this->path;
166 166
 		}
167 167
 
Please login to merge, or discard this patch.
tests/RequestTest.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -15,7 +15,6 @@
 block discarded – undo
15 15
 use chillerlan\TinyCurl\RequestOptions;
16 16
 use chillerlan\TinyCurl\Response\Response;
17 17
 use chillerlan\TinyCurl\URL;
18
-use stdClass;
19 18
 
20 19
 class RequestTest extends \PHPUnit_Framework_TestCase{
21 20
 
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 use chillerlan\TinyCurl\URL;
18 18
 use stdClass;
19 19
 
20
-class RequestTest extends \PHPUnit_Framework_TestCase{
20
+class RequestTest extends \PHPUnit_Framework_TestCase {
21 21
 
22 22
 	const GW2_APIKEY = '39519066-20B0-5545-9AE2-71109410A2CAF66348DA-50F7-4ACE-9363-B38FD8EE1881';
23 23
 	const GW2_ACC_ID = 'A9EAD53E-4157-E111-BBF3-78E7D1936222';
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	protected $response;
41 41
 
42
-	protected function setUp(){
42
+	protected function setUp() {
43 43
 
44 44
 		$co = [
45 45
 			CURLOPT_HTTPHEADER => ['Authorization: Bearer '.self::GW2_APIKEY]
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 		$this->requestNoCA = new Request($o2);
56 56
 	}
57 57
 
58
-	public function testInstanceWithoutArgsCoverage(){
58
+	public function testInstanceWithoutArgsCoverage() {
59 59
 		$this->assertInstanceOf(Request::class, new Request); // HA HA.
60 60
 	}
61 61
 
62
-	public function fetchDataProvider(){
62
+	public function fetchDataProvider() {
63 63
 		return [
64 64
 			['https://api.guildwars2.com/v2/account', []],
65 65
 			['https://api.guildwars2.com/v2/account?lang=de', []],
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	/**
71 71
 	 * @dataProvider fetchDataProvider
72 72
 	 */
73
-	public function testFetchWithCA($url, array $params){
73
+	public function testFetchWithCA($url, array $params) {
74 74
 		$this->response = $this->requestWithCA->fetch(new URL($url, $params));
75 75
 
76 76
 		$this->assertEquals(0, $this->response->error->code);
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
 	/**
84 84
 	 * @dataProvider fetchDataProvider
85 85
 	 */
86
-	public function testFetchNoCA($url, array $params){
86
+	public function testFetchNoCA($url, array $params) {
87 87
 		$this->response = $this->requestNoCA->fetch(new URL($url, $params));
88 88
 
89 89
 		$this->assertEquals(0, $this->response->error->code);
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @expectedException \chillerlan\TinyCurl\RequestException
98 98
 	 * @expectedExceptionMessage $url
99 99
 	 */
100
-	public function testFetchUrlSchemeException(){
100
+	public function testFetchUrlSchemeException() {
101 101
 		$this->requestWithCA->fetch(new URL('htps://whatever.wat'));
102 102
 	}
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 	 * @expectedException \chillerlan\TinyCurl\Response\ResponseException
106 106
 	 * @expectedExceptionMessage $curl
107 107
 	 */
108
-	public function testResponseNoCurlException(){
108
+	public function testResponseNoCurlException() {
109 109
 		$this->response = new Response(null);
110 110
 	}
111 111
 
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 	 * @expectedException \chillerlan\TinyCurl\Response\ResponseException
114 114
 	 * @expectedExceptionMessage !$property: foobar
115 115
 	 */
116
-	public function testResponseGetMagicFieldException(){
116
+	public function testResponseGetMagicFieldException() {
117 117
 		var_dump($this->requestWithCA->fetch(new URL('https://api.guildwars2.com/v2/build'))->foobar);
118 118
 	}
119 119
 
Please login to merge, or discard this patch.
tests/ExtractUrlTest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
 use chillerlan\TinyCurl\Request;
15 15
 use chillerlan\TinyCurl\RequestOptions;
16 16
 
17
-class ExtractUrlTest extends \PHPUnit_Framework_TestCase{
17
+class ExtractUrlTest extends \PHPUnit_Framework_TestCase {
18 18
 
19 19
 	/**
20 20
 	 * @var \chillerlan\TinyCurl\Request
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	 */
27 27
 	protected $requestNoCA;
28 28
 
29
-	protected function setUp(){
29
+	protected function setUp() {
30 30
 		$co = [CURLOPT_FOLLOWLOCATION => false];
31 31
 
32 32
 		$o1 = new RequestOptions;
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 		$this->requestNoCA = new Request($o2);
40 40
 	}
41 41
 
42
-	public function shortURLDataProvider(){
42
+	public function shortURLDataProvider() {
43 43
 		return [
44 44
 			[
45 45
 				[
@@ -75,14 +75,14 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @dataProvider shortURLDataProvider
77 77
 	 */
78
-	public function testExtractShortUrlWithCA($expected){
78
+	public function testExtractShortUrlWithCA($expected) {
79 79
 			$this->assertEquals($expected, $this->requestWithCA->extractShortUrl($expected[0]));
80 80
 		}
81 81
 
82 82
 	/**
83 83
 	 * @dataProvider shortURLDataProvider
84 84
 	 */
85
-		public function testExtractShortUrlNoCA($expected){
85
+		public function testExtractShortUrlNoCA($expected) {
86 86
 			$this->assertEquals($expected, $this->requestNoCA->extractShortUrl($expected[0]));
87 87
 		}
88 88
 
Please login to merge, or discard this patch.
tests/MultiRequestTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,19 +15,19 @@  discard block
 block discarded – undo
15 15
 use chillerlan\TinyCurl\MultiRequestOptions;
16 16
 use stdClass;
17 17
 
18
-class MultiRequestTest extends \PHPUnit_Framework_TestCase{
18
+class MultiRequestTest extends \PHPUnit_Framework_TestCase {
19 19
 
20
-	protected function getURLs(){
20
+	protected function getURLs() {
21 21
 
22 22
 		$ids = [
23
-			[1,2,6,11,15,23,24,56,57,58,59,60,61,62,63,64,68,69,70,71,72,73,74,75,76],
24
-			[77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101],
23
+			[1, 2, 6, 11, 15, 23, 24, 56, 57, 58, 59, 60, 61, 62, 63, 64, 68, 69, 70, 71, 72, 73, 74, 75, 76],
24
+			[77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101],
25 25
 		];
26 26
 
27 27
 		$urls = [];
28 28
 
29
-		foreach($ids as $chunk){
30
-			foreach(['de', 'en', 'es', 'fr', 'zh'] as $lang){
29
+		foreach ($ids as $chunk) {
30
+			foreach (['de', 'en', 'es', 'fr', 'zh'] as $lang) {
31 31
 				$urls[] = 'lang='.$lang.'&ids='.implode(',', $chunk);
32 32
 			}
33 33
 		}
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 		return $urls;
36 36
 	}
37 37
 
38
-	public function testInstance(){
38
+	public function testInstance() {
39 39
 		$options = new MultiRequestOptions;
40 40
 		$options->handler     = MultiResponseHandlerTest::class;
41 41
 		$options->ca_info     = __DIR__.'/test-cacert.pem';
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		$request = new MultiRequest($options);
46 46
 		$request->fetch($this->getURLs());
47 47
 
48
-		foreach($request->getResponseData() as $response){
48
+		foreach ($request->getResponseData() as $response) {
49 49
 
50 50
 			$this->assertEquals(0, $response->errorcode);
51 51
 			$this->assertEquals(200, $response->statuscode);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 
57 57
 	}
58 58
 
59
-	public function testInstanceWindowSize(){
59
+	public function testInstanceWindowSize() {
60 60
 		$options = new MultiRequestOptions;
61 61
 		$options->handler     = MultiResponseHandlerTest::class;
62 62
 		$options->ca_info     = __DIR__.'/test-cacert.pem';
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 * @expectedException \chillerlan\TinyCurl\RequestException
72 72
 	 * @expectedExceptionMessage empty($urls)
73 73
 	 */
74
-	public function testFetchUrlEmptyException(){
74
+	public function testFetchUrlEmptyException() {
75 75
 		(new MultiRequest)->fetch([]);
76 76
 	}
77 77
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * @expectedException \chillerlan\TinyCurl\RequestException
80 80
 	 * @expectedExceptionMessage !$this->options->handler
81 81
 	 */
82
-	public function testSetHandlerExistsException(){
82
+	public function testSetHandlerExistsException() {
83 83
 		$options = new MultiRequestOptions;
84
-		$options->handler     = 'foobar';
84
+		$options->handler = 'foobar';
85 85
 
86 86
 		new MultiRequest($options);
87 87
 	}
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @expectedException \chillerlan\TinyCurl\RequestException
91 91
 	 * @expectedExceptionMessage !is_a($handler)
92 92
 	 */
93
-	public function testSetHandlerImplementsException(){
93
+	public function testSetHandlerImplementsException() {
94 94
 		$options = new MultiRequestOptions;
95
-		$options->handler     = stdClass::class;
95
+		$options->handler = stdClass::class;
96 96
 
97 97
 		new MultiRequest($options);
98 98
 	}
Please login to merge, or discard this patch.
tests/MultiResponseHandlerTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  *
22 22
  */
23
-class MultiResponseHandlerTest implements MultiResponseHandlerInterface{
23
+class MultiResponseHandlerTest implements MultiResponseHandlerInterface {
24 24
 
25 25
 	/**
26 26
 	 * @var \chillerlan\TinyCurl\MultiRequest
27 27
 	 */
28 28
 	protected $request;
29 29
 
30
-	public function __construct(MultiRequest $request){
30
+	public function __construct(MultiRequest $request) {
31 31
 		$this->request = $request;
32 32
 	}
33 33
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 	 *
37 37
 	 * @return mixed
38 38
 	 */
39
-	public function handleResponse(ResponseInterface $response){
39
+	public function handleResponse(ResponseInterface $response) {
40 40
 		$data = new stdClass;
41 41
 		$data->errorcode             = $response->error->code;
42 42
 		$data->statuscode            = $response->info->http_code;
Please login to merge, or discard this patch.