Skip to content

Commit

Permalink
Merge pull request #1 from mettleworks/feature/upgrade-dependencies
Browse files Browse the repository at this point in the history
Feature/upgrade dependencies
  • Loading branch information
mauricius authored Jan 21, 2021
2 parents 49d6d99 + 346076e commit 625f9fb
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.idea
.phpunit.result.cache
build
composer.lock
vendor
Expand Down
7 changes: 4 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
}
],
"require": {
"php" : "~7.1",
"guzzlehttp/guzzle": "~6.0"
"php" : "^7.3",
"ext-json": "*",
"guzzlehttp/guzzle": "^7.0.1"
},
"require-dev": {
"phpunit/phpunit" : ">=7.0",
Expand All @@ -42,7 +43,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
"dev-master": "1.1-dev"
}
},
"config": {
Expand Down
19 changes: 7 additions & 12 deletions src/BigHugeThesaurusClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ public function __construct(string $key)
/**
* Sets the client to be used for querying the API endpoints
*
* @param Client $client
* @param Client|null $client
* @return $this
*/
public function setHttpClient(Client $client = null)
public function setHttpClient(Client $client = null): BigHugeThesaurusClient
{
if ($client === null) {
$client = new Client([
Expand Down Expand Up @@ -113,11 +113,10 @@ public function getBaseUri()
* @param string $word
* @return ThesaurusResponse
* @throws NotFoundException
* @throws RemoteException
* @throws GuzzleException
* @see https://words.bighugelabs.com/api.php
*/
public function lookup(string $word)
public function lookup(string $word): ThesaurusResponse
{
try {
if (!$this->getHttpClient()) {
Expand Down Expand Up @@ -149,7 +148,6 @@ public function lookup(string $word)
*
* @param string $word
* @throws NotFoundException
* @throws RemoteException
* @throws GuzzleException
* @return array
*/
Expand All @@ -165,7 +163,6 @@ public function synonymsOf(string $word): array
*
* @param string $word
* @throws NotFoundException
* @throws RemoteException
* @throws GuzzleException
* @return array
*/
Expand All @@ -181,7 +178,6 @@ public function antonymsOf(string $word): array
*
* @param string $word
* @throws NotFoundException
* @throws RemoteException
* @throws GuzzleException
* @return array
*/
Expand All @@ -197,7 +193,6 @@ public function similarTermsOf(string $word): array
*
* @param string $word
* @throws NotFoundException
* @throws RemoteException
* @throws GuzzleException
* @return array
*/
Expand All @@ -211,20 +206,20 @@ public function relatedTermsOf(string $word): array
/**
* Get the raw response
*
* @return ThesaurusResponse
* @return string
*/
public function getRawResponse()
public function getRawResponse(): string
{
return $this->rawResponse;
}

/**
* Parse the response into a ThesaurusResponse
*
* @param string $response
* @param string $response
* @return ThesaurusResponse
*/
protected function parseResponse($response)
protected function parseResponse(string $response): ThesaurusResponse
{
$parsed = json_decode($response, true);

Expand Down
2 changes: 1 addition & 1 deletion src/ThesaurusResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public function toArray(): array
*
* @return string
*/
public function toJson()
public function toJson(): string
{
return json_encode($this->response);
}
Expand Down
7 changes: 5 additions & 2 deletions tests/BigHugeThesaurusClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class BigHugeThesaurusClientTest extends TestCase
protected $mockHandler;
protected $httpClient;

protected function setUp()
protected function setUp(): void
{
$this->mockHandler = new MockHandler();

Expand Down Expand Up @@ -137,13 +137,16 @@ public function itShouldProvideTheThesaurusResponseIfTheLookupSucceeds()
/** @test */
public function itShouldReturnTheRawResponseFromTheClient()
{
$this->mockHandler->append(new Response(200, [], file_get_contents(__DIR__ . '/fixtures/love.json')));
$response = file_get_contents(__DIR__ . '/fixtures/love.json');

$this->mockHandler->append(new Response(200, [], $response));

$apiClient = $this->createClient('123');

$apiClient->lookup('love');

$this->assertIsString($apiClient->getRawResponse());
$this->assertEquals($response, $apiClient->getRawResponse());
}

/** @test */
Expand Down

0 comments on commit 625f9fb

Please sign in to comment.