Skip to content

Commit 47bbd5f

Browse files
committed
Changes based on peer review
1 parent 3797edf commit 47bbd5f

7 files changed

Lines changed: 27 additions & 41 deletions

File tree

.github/CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ And there are not coding standard violations by running
1818
```
1919

2020
## Builds
21-
Our [Travis build](https://travis-ci.org/traderinteractive/util-file-php) executes [PHPUnit](http://www.phpunit.de) and uses [Coveralls](https://coveralls.io/) to enforce code coverage.
21+
Our [Travis build](https://travis-ci.org/traderinteractive/tol-api-php) executes [PHPUnit](http://www.phpunit.de) and uses [Coveralls](https://coveralls.io/) to enforce code coverage.
2222
While the build does not strictly enforce 100% code coverage, it will not allow coverage to drop below its current percentage.
2323
[Scrutinizer](https://scrutinizer-ci.com/) is used to ensure code quality and enforce the [coding standard](http://www.php-fig.org/psr/psr-2/).

src/Authentication.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ private function __construct(callable $getTokenRequestFunc)
3333
/**
3434
* Creates a new instance of Authentication for Client Credentials grant type
3535
*
36-
* @param string $clientId The oauth client id
37-
* @param string $clientSecret The oauth client secret
38-
* @param string $refreshResource The refresh token resource of the API
39-
* Only needed since apigee doesnt use the token resource that is in the oauth2 spec
36+
* @param string $clientId The oauth client id
37+
* @param string $clientSecret The oauth client secret
38+
* @param string $refreshResource The refresh token resource of the API Only needed since apigee doesnt use the
39+
* token resource that is in the oauth2 spec
40+
* @param string $tokenResource The access token resource of the API
4041
*
4142
* @return Authentication
4243
*/
@@ -80,12 +81,13 @@ public static function createClientCredentials(
8081
/**
8182
* Creates a new instance of Authentication for Owner Credentials grant type
8283
*
83-
* @param string $clientId The oauth client id
84-
* @param string $clientSecret The oauth client secret
85-
* @param string $username The oauth username
86-
* @param string $password The oauth password
87-
* @param string $refreshResource The refresh token resource of the API
88-
* Only needed since apigee doesnt use the token resource that is in the oauth2 spec
84+
* @param string $clientId The oauth client id
85+
* @param string $clientSecret The oauth client secret
86+
* @param string $username The oauth username
87+
* @param string $password The oauth password
88+
* @param string $refreshResource The refresh token resource of the API. Only needed since apigee doesnt use the
89+
* token resource that is in the oauth2 spec
90+
* @param string $tokenResource The access token resource of the API
8991
*
9092
* @return Authentication
9193
*/

src/Client.php

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use TraderInteractive\Util\Http;
99
use GuzzleHttp\Psr7\Request;
1010
use Psr\Http\Message\ResponseInterface;
11+
use Psr\Http\Message\RequestInterface;
1112
use Psr\SimpleCache\CacheInterface;
1213

1314
/**
@@ -62,50 +63,36 @@ final class Client implements ClientInterface
6263
];
6364

6465
/**
65-
* Base url of the API server
66-
*
6766
* @var string
6867
*/
6968
private $baseUrl;
7069

7170
/**
72-
* HTTP Adapter for sending request to the api
73-
*
7471
* @var AdapterInterface
7572
*/
7673
private $adapter;
7774

7875
/**
79-
* Oauth authentication implementation
80-
*
8176
* @var Authentication
8277
*/
8378
private $authentication;
8479

8580
/**
86-
* API access token
87-
*
8881
* @var string
8982
*/
9083
private $accessToken;
9184

9285
/**
93-
* API refresh token
94-
*
9586
* @var string
9687
*/
9788
private $refreshToken;
9889

9990
/**
100-
* Storage for cached API responses
101-
*
10291
* @var CacheInterface
10392
*/
10493
private $cache;
10594

10695
/**
107-
* Strategy for caching
108-
*
10996
* @var int
11097
*/
11198
private $cacheMode;
@@ -127,13 +114,13 @@ final class Client implements ClientInterface
127114
/**
128115
* Create a new instance of Client
129116
*
130-
* @param AdapterInterface $adapter
131-
* @param Authentication $authentication
132-
* @param string $baseUrl
133-
* @param int $cacheMode
134-
* @param Cache $cache
135-
* @param string $accessToken
136-
* @param string $refreshToken
117+
* @param AdapterInterface $adapter HTTP Adapter for sending request to the api
118+
* @param Authentication $authentication Oauth authentication implementation
119+
* @param string $baseUrl Base url of the API server
120+
* @param int $cacheMode Strategy for caching
121+
* @param CacheInterface $cache Storage for cached API responses
122+
* @param string $accessToken API access token
123+
* @param string $refreshToken API refresh token
137124
*
138125
* @throws \InvalidArgumentException Thrown if $baseUrl is not a non-empty string
139126
* @throws \InvalidArgumentException Thrown if $cacheMode is not one of the cache mode constants
@@ -463,7 +450,7 @@ private function start(string $url, string $method, string $body = null, array $
463450
return $key;
464451
}
465452

466-
private function getCacheKey(Request $request) : string
453+
private function getCacheKey(RequestInterface $request) : string
467454
{
468455
return CacheHelper::getCacheKey($request);
469456
}

src/ClientInterface.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
<?php
22
namespace TraderInteractive\Api;
33

4-
use Psr\Http\Message\RequestInterface;
5-
64
/**
75
* Client for apis
86
*/

src/Collection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ final class Collection implements \Iterator, \Countable
6868
/**
6969
* Create a new collection
7070
*
71-
* @param Client $client client connection to the API
72-
* @param string $resource name of API resource to request
73-
* @param array $filters key value pair array of search filters
71+
* @param ClientInterface $client Configured client connection to the API.
72+
* @param string $resource The name of API resource to request.
73+
* @param array $filters A key value pair array of search filters.
7474
*/
7575
public function __construct(ClientInterface $client, string $resource, array $filters = [])
7676
{

src/GuzzleAdapter.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,9 @@ public function end(string $endHandle) : ResponseInterface
7373
$results = $this->fulfillPromises($this->promises, $this->exceptions);
7474
foreach ($results as $handle => $response) {
7575
try {
76-
$body = []; //default to empty body
7776
$contents = (string)$response->getBody();
7877
if (trim($contents) !== '') {
79-
$body = json_decode($contents, true);
78+
json_decode($contents, true);
8079
Util::ensure(
8180
JSON_ERROR_NONE,
8281
json_last_error(),

src/Response.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function getResponseHeaders() : array
7676
return $this->headers;
7777
}
7878

79-
public static function fromPsr7Response(ResponseInterface $response)
79+
public static function fromPsr7Response(ResponseInterface $response) : Response
8080
{
8181
return new self(
8282
$response->getStatusCode(),

0 commit comments

Comments
 (0)