Skip to content

Commit ffb193e

Browse files
author
Martin Brecht-Precht
committed
Language level migration.
1 parent 4425c02 commit ffb193e

27 files changed

+312
-460
lines changed

.codeclimate.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

.travis.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

composer.json

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
{
2-
"name": "markenwerk/basic-http-client",
3-
"type": "library",
4-
"description": "A basic yet extensible HTTP client library providing different authentication methods written in PHP.",
5-
"keywords": [
6-
"HTTP client",
7-
"RESTful",
8-
"JSON",
9-
"SSL",
10-
"Basic Auth",
11-
"Client Certificate Auth"
12-
],
13-
"homepage": "http://markenwerk.net/",
14-
"license": "MIT",
15-
"authors": [
16-
{
17-
"name": "Martin Brecht-Precht",
18-
"email": "mb@markenwerk.net",
19-
"homepage": "http://markenwerk.net"
20-
}
21-
],
22-
"autoload": {
23-
"psr-4": {
24-
"Markenwerk\\BasicHttpClient\\": "src/"
25-
}
26-
},
27-
"require": {
28-
"php": ">=5.3",
29-
"lib-curl": "*",
30-
"markenwerk/url-util": "~2.0",
31-
"markenwerk/common-exceptions": "~3.0"
32-
},
33-
"require-dev": {
34-
"phpunit/phpunit": ">=4.8.26",
35-
"codeclimate/php-test-reporter": "dev-master"
36-
}
2+
"name": "markenwerk/basic-http-client",
3+
"type": "library",
4+
"description": "A basic yet extensible HTTP client library providing different authentication methods written in PHP.",
5+
"keywords": [
6+
"HTTP client",
7+
"RESTful",
8+
"JSON",
9+
"SSL",
10+
"Basic Auth",
11+
"Client Certificate Auth"
12+
],
13+
"homepage": "http://markenwerk.net/",
14+
"license": "MIT",
15+
"authors": [
16+
{
17+
"name": "Martin Brecht-Precht",
18+
"email": "mb@markenwerk.net",
19+
"homepage": "http://markenwerk.net"
20+
}
21+
],
22+
"autoload": {
23+
"psr-4": {
24+
"Markenwerk\\BasicHttpClient\\": "src/"
25+
}
26+
},
27+
"require": {
28+
"php": "^7.1",
29+
"ext-curl": "*",
30+
"ext-mbstring": "*",
31+
"markenwerk/url-util": "~2.0",
32+
"markenwerk/common-exceptions": "~3.0"
33+
}
3734
}

phpunit.xml.dist

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/BasicHttpClient.php

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,11 @@ class BasicHttpClient implements HttpClientInterface
3131
*
3232
* @param string $endpoint
3333
*/
34-
public function __construct($endpoint)
34+
public function __construct(string $endpoint)
3535
{
36-
if (!is_string($endpoint)) {
37-
$argumentType = (is_object($endpoint)) ? get_class($endpoint) : gettype($endpoint);
38-
throw new \InvalidArgumentException('Expected the endpoint as string. Got ' . $argumentType);
39-
}
4036
$url = new Url($endpoint);
4137
$transport = new HttpTransport();
42-
if (mb_strtoupper($url->getScheme()) == 'HTTPS') {
38+
if (mb_strtoupper($url->getScheme()) === 'HTTPS') {
4339
$transport = new HttpsTransport();
4440
}
4541
$this->request = new Request();
@@ -52,7 +48,7 @@ public function __construct($endpoint)
5248
/**
5349
* @return RequestInterface
5450
*/
55-
public function getRequest()
51+
public function getRequest(): RequestInterface
5652
{
5753
return $this->request;
5854
}
@@ -63,7 +59,7 @@ public function getRequest()
6359
* @throws NetworkException
6460
* @throws ConnectionTimeoutException
6561
*/
66-
public function get(array $queryParameters = array())
62+
public function get(array $queryParameters = array()): ResponseInterface
6763
{
6864
$this->request
6965
->setMethod(RequestInterface::REQUEST_METHOD_GET)
@@ -79,7 +75,7 @@ public function get(array $queryParameters = array())
7975
* @throws NetworkException
8076
* @throws ConnectionTimeoutException
8177
*/
82-
public function head(array $queryParameters = array())
78+
public function head(array $queryParameters = array()): ResponseInterface
8379
{
8480
$this->request
8581
->setMethod(RequestInterface::REQUEST_METHOD_HEAD)
@@ -95,7 +91,7 @@ public function head(array $queryParameters = array())
9591
* @throws NetworkException
9692
* @throws ConnectionTimeoutException
9793
*/
98-
public function post(array $postData = array())
94+
public function post(array $postData = array()): ResponseInterface
9995
{
10096
$body = new Body();
10197
$body->setBodyTextFromArray($postData);
@@ -114,7 +110,7 @@ public function post(array $postData = array())
114110
* @throws NetworkException
115111
* @throws ConnectionTimeoutException
116112
*/
117-
public function put(array $putData = array())
113+
public function put(array $putData = array()): ResponseInterface
118114
{
119115
$body = new Body();
120116
$body->setBodyTextFromArray($putData);
@@ -133,7 +129,7 @@ public function put(array $putData = array())
133129
* @throws NetworkException
134130
* @throws ConnectionTimeoutException
135131
*/
136-
public function patch(array $patchData = array())
132+
public function patch(array $patchData = array()): ResponseInterface
137133
{
138134
$body = new Body();
139135
$body->setBodyTextFromArray($patchData);
@@ -152,7 +148,7 @@ public function patch(array $patchData = array())
152148
* @throws NetworkException
153149
* @throws ConnectionTimeoutException
154150
*/
155-
public function delete(array $queryParameters = array())
151+
public function delete(array $queryParameters = array()): ResponseInterface
156152
{
157153
$this->request
158154
->setMethod(RequestInterface::REQUEST_METHOD_DELETE)

src/HttpClientInterface.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,42 +16,42 @@ interface HttpClientInterface
1616
/**
1717
* @return RequestInterface
1818
*/
19-
public function getRequest();
19+
public function getRequest(): RequestInterface;
2020

2121
/**
2222
* @param mixed[] $queryParameters
2323
* @return ResponseInterface
2424
*/
25-
public function get(array $queryParameters = array());
25+
public function get(array $queryParameters = array()): ResponseInterface;
2626

2727
/**
2828
* @param mixed[] $queryParameters
2929
* @return ResponseInterface
3030
*/
31-
public function head(array $queryParameters = array());
31+
public function head(array $queryParameters = array()): ResponseInterface;
3232

3333
/**
3434
* @param array $postData
3535
* @return ResponseInterface
3636
*/
37-
public function post(array $postData = array());
37+
public function post(array $postData = array()): ResponseInterface;
3838

3939
/**
4040
* @param array $putData
4141
* @return ResponseInterface
4242
*/
43-
public function put(array $putData = array());
43+
public function put(array $putData = array()): ResponseInterface;
4444

4545
/**
4646
* @param array $patchData
4747
* @return ResponseInterface
4848
*/
49-
public function patch(array $patchData = array());
49+
public function patch(array $patchData = array()): ResponseInterface;
5050

5151
/**
5252
* @param mixed[] $queryParameters
5353
* @return ResponseInterface
5454
*/
55-
public function delete(array $queryParameters = array());
55+
public function delete(array $queryParameters = array()): ResponseInterface;
5656

5757
}

0 commit comments

Comments
 (0)