Skip to content

Commit

Permalink
Merge pull request #394 from HubSpot/feature/csfix
Browse files Browse the repository at this point in the history
Code Style fix
  • Loading branch information
ksvirkou-hubspot authored Aug 12, 2022
2 parents bd2355e + 85ee249 commit 32742d3
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Endpoints/Files.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ class Files extends Endpoint
* @param resource|string $file
*
* @return \SevenShores\Hubspot\Http\Response
*@see https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file
*
*@see https://legacydocs.hubspot.com/docs/methods/files/v3/upload_new_file
*/
public function upload(
$file,
Expand Down
2 changes: 1 addition & 1 deletion src/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Endpoint;
use SevenShores\Hubspot\Http\Client;

/**
* Class Factory.
Expand Down
2 changes: 2 additions & 0 deletions src/Http/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,13 @@ public function request(string $method, string $endpoint, array $options = [], $
if (false === $this->wrapResponse) {
throw $e;
}

throw HubspotException::create($e);
} catch (ClientException $e) {
if (false === $this->wrapResponse) {
throw $e;
}

throw BadRequest::create($e);
}
}
Expand Down
5 changes: 1 addition & 4 deletions src/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Response implements ResponseInterface, ArrayAccess
* @var mixed
*/
public $data;

/**
* @var \Psr\Http\Message\ResponseInterface
*/
Expand Down Expand Up @@ -59,8 +60,6 @@ public function toArray()
* Whether a offset exists.
*
* @param mixed $offset
*
* @return bool
*/
public function offsetExists($offset): bool
{
Expand All @@ -71,8 +70,6 @@ public function offsetExists($offset): bool
* Offset to retrieve.
*
* @param mixed $offset
*
* @return mixed
*/
public function offsetGet($offset): mixed
{
Expand Down
6 changes: 4 additions & 2 deletions src/RetryMiddlewareFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public static function createMiddlewareByHttpCodes(
array $codes,
callable $delayFunction,
int $maxRetries = 5
): callable {
): callable
{
return Middleware::retry(
static::getRetryFunction($codes, $maxRetries),
$delayFunction
Expand All @@ -47,7 +48,8 @@ public static function createMiddlewareByHttpCodeRange(
int $to,
callable $delayFunction,
int $maxRetries = 5
): callable {
): callable
{
return Middleware::retry(
static::getRetryFunctionByRange($from, $to, $maxRetries),
$delayFunction
Expand Down
4 changes: 2 additions & 2 deletions src/Utils/Webhooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class Webhooks
{
/**
* Validation of Hubspot Signature.
*
*
* @deprecated
*
*
* @param string $signature hubspot signarute
* @param string $secret the Secret of your app
* @param string $requestBody a set of scopes that your app will need access to
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Abstraction/BlogPostTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
namespace SevenShores\Hubspot\Tests\Integration\Abstraction;

use DateTime;
use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\BlogAuthors;
use SevenShores\Hubspot\Endpoints\BlogPosts;
use SevenShores\Hubspot\Endpoints\Blogs;
use SevenShores\Hubspot\Http\Client;

abstract class BlogPostTestCase extends EntityTestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/BlogCommentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\BlogComments;
use SevenShores\Hubspot\Endpoints\BlogPosts;
use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Tests\Integration\Abstraction\BlogPostTestCase;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/CalendarEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function allTasks()
protected function createEntity()
{
return $this->resource->createTask([
'eventDate' => strtotime('+1 day') * 1000, //timestamp in milliseconds
'eventDate' => strtotime('+1 day') * 1000, // timestamp in milliseconds
'eventType' => 'PUBLISHING_TASK',
'category' => 'EMAIL',
'state' => 'TODO',
Expand Down
10 changes: 5 additions & 5 deletions tests/Integration/Endpoints/DealsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Companies;
use SevenShores\Hubspot\Endpoints\Contacts;
use SevenShores\Hubspot\Endpoints\Deals;
use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Tests\Integration\Abstraction\EntityTestCase;

/**
Expand Down Expand Up @@ -178,7 +178,7 @@ public function associateAndDisassociateWithCompany()
]);
$this->assertEquals(204, $associateResponse->getStatusCode());

//Check what was associated
// Check what was associated
$byIdResponse = $this->resource->getById($this->entity->dealId);

$associatedCompanies = $byIdResponse->associations->associatedCompanyIds;
Expand All @@ -189,7 +189,7 @@ public function associateAndDisassociateWithCompany()

$this->assertEquals($expectedAssociatedCompanies, $associatedCompanies);

//Now disassociate
// Now disassociate
$response = $this->resource->disassociateFromCompany($this->entity->dealId, [
$firstCompanyId,
$secondCompanyId,
Expand Down Expand Up @@ -218,7 +218,7 @@ public function associateAndDisassociateWithContact()
]);
$this->assertSame(204, $associateResponse->getStatusCode());

//Check what was associated
// Check what was associated
$byIdResponse = $this->resource->getById($this->entity->dealId);

$associatedContacts = $byIdResponse->associations->associatedVids;
Expand All @@ -229,7 +229,7 @@ public function associateAndDisassociateWithContact()

$this->assertEquals($expectedAssociatedContacts, $associatedContacts);

//Now disassociate
// Now disassociate
$response = $this->resource->disassociateFromContact($this->entity->dealId, [
$firstContactId,
$secondContactId,
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/EmailEventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\EmailEvents;
use SevenShores\Hubspot\Http\Client;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/EmailSubscriptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\EmailSubscription;
use SevenShores\Hubspot\Http\Client;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/EventsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Events;
use SevenShores\Hubspot\Http\Client;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Integration;
use SevenShores\Hubspot\Http\Client;

/**
* Class IntegrationTest.
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/KeywordsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Keywords;
use SevenShores\Hubspot\Http\Client;

/**
* @internal
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/LineItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\LineItems;
use SevenShores\Hubspot\Endpoints\Products;
use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Tests\Integration\Abstraction\EntityTestCase;

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/Integration/Endpoints/OwnersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace SevenShores\Hubspot\Tests\Integration\Endpoints;

use SevenShores\Hubspot\Http\Client;
use SevenShores\Hubspot\Endpoints\Owners;
use SevenShores\Hubspot\Http\Client;

/**
* Class OwnersTest.
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/Support/QueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,15 @@ public function encodeFalse()
public function buildDataProvider()
{
yield 'string' => [['firstname' => 'joe', 'lastname' => 'blo'], '&firstname=joe&lastname=blo'];

yield 'int' => [['firstname' => 'joe', 'active' => 1], '&firstname=joe&active=1'];

yield 'bool true' => [['firstname' => 'joe', 'active' => true], '&firstname=joe&active=true'];

yield 'bool false' => [['firstname' => 'joe', 'active' => false], '&firstname=joe'];

yield 'empty array' => [['firstname' => 'joe', 'property' => []], '&firstname=joe'];

yield 'array' => [['firstname' => 'joe', 'property' => ['foo']], '&firstname=joe&property=foo'];
}
}
4 changes: 2 additions & 2 deletions tests/unit/Utils/SignatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function validationHubspotSignatureValidData()
$result = Utils\Signature::isValid([
'signature' => hash('sha256', $this->secret.$this->requestBody),
'secret' => $this->secret,
'requestBody' => $this->requestBody
'requestBody' => $this->requestBody,
]);

$this->assertEquals(
Expand All @@ -34,7 +34,7 @@ public function validationHubspotSignatureInvalidData()
$result = Utils\Signature::isValid([
'signature' => hash('sha256', $this->secret.$this->requestBody.'1'),
'secret' => $this->secret,
'requestBody' => $this->requestBody
'requestBody' => $this->requestBody,
]);

$this->assertEquals(
Expand Down

0 comments on commit 32742d3

Please sign in to comment.