Skip to content

Commit

Permalink
Fixes coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
Naoray authored and github-actions[bot] committed Dec 18, 2024
1 parent 30ed85c commit b5aac11
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Contracts/ResourceDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
interface ResourceDecorator
{
/**
* @param Response|BaseResource|BaseCollection|LazyCollection $resource
* @param Response|BaseResource|BaseCollection|LazyCollection $resource
*/
public static function fromResource($resource): self;
}
5 changes: 2 additions & 3 deletions src/Http/Requests/ResourceHydratableRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ public function getHydratableResource()
}

/**
* @param string|DecorateResource $hydratableResource
* @return self
* @param string|DecorateResource $hydratableResource
*/
public function setHydratableResource($hydratableResource): self
{
Expand All @@ -49,7 +48,7 @@ public function setHydratableResource($hydratableResource): self
}

if ($hydratableResource instanceof DecorateResource && ! $hydratableResource->getDecorator()) {
throw new \InvalidArgumentException("The decorator class is not set.");
throw new \InvalidArgumentException('The decorator class is not set.');
}

$this->customHydratableResource = $hydratableResource;
Expand Down
6 changes: 2 additions & 4 deletions src/Resources/ResourceFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
namespace Mollie\Api\Resources;

use Mollie\Api\Contracts\Connector;
use Mollie\Api\Contracts\ResourceDecorator;
use Mollie\Api\Contracts\EmbeddedResourcesContract;
use Mollie\Api\Contracts\ResourceDecorator;
use Mollie\Api\Exceptions\EmbeddedResourcesNotParseableException;
use Mollie\Api\Http\Response;

Expand Down Expand Up @@ -61,9 +61,7 @@ public static function createBaseResourceCollection(
/**
* Create a decorated resource from a response or existing resource.
*
* @param Response|BaseResource|BaseCollection|LazyCollection $response
* @param string $decorator
* @return ResourceDecorator
* @param Response|BaseResource|BaseCollection|LazyCollection $response
*/
public static function createDecoratedResource($response, string $decorator): ResourceDecorator
{
Expand Down
13 changes: 8 additions & 5 deletions tests/Resources/ResourceFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Tests\Resources;

use Mollie\Api\Contracts\ResourceDecorator;
use Mollie\Api\Http\Response;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Resources\AnyResource;
use Mollie\Api\Resources\BaseCollection;
use Mollie\Api\Resources\Client;
use Mollie\Api\Resources\Onboarding;
use Mollie\Api\Resources\Payment;
use Mollie\Api\Resources\PaymentCollection;
use Mollie\Api\Resources\RefundCollection;
use Mollie\Api\Resources\ResourceFactory;
use Mollie\Api\Contracts\ResourceDecorator;
use Mollie\Api\Resources\BaseCollection;
use PHPUnit\Framework\TestCase;

class ResourceFactoryTest extends TestCase
Expand Down Expand Up @@ -128,7 +128,7 @@ public function embedded_resources_are_type_casted()
/** @test */
public function it_throws_exception_when_response_is_missing()
{
$apiResult = new \stdClass();
$apiResult = new \stdClass;

$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('Response is required');
Expand Down Expand Up @@ -190,7 +190,7 @@ public function it_creates_base_resource_collection()
$response = $this->createMock(Response::class);
$data = [
['id' => 'payment-1', 'resource' => 'payment'],
['id' => 'payment-2', 'resource' => 'payment']
['id' => 'payment-2', 'resource' => 'payment'],
];

$collection = ResourceFactory::createBaseResourceCollection(
Expand All @@ -211,7 +211,7 @@ public function it_creates_base_resource_collection_with_custom_collection_class
{
$response = $this->createMock(Response::class);
$data = [
['id' => 'payment-1', 'resource' => 'payment']
['id' => 'payment-1', 'resource' => 'payment'],
];

$collection = ResourceFactory::createBaseResourceCollection(
Expand Down Expand Up @@ -289,8 +289,11 @@ class CustomPaymentCollection extends BaseCollection
class CustomResourceDecorator implements ResourceDecorator
{
public string $status;

public bool $canReceivePayments;

public bool $canReceiveSettlements;

public string $dashboardUrl;

public function __construct(
Expand Down
30 changes: 16 additions & 14 deletions tests/Resources/ResourceHydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@
use Mollie\Api\Contracts\ResourceDecorator;
use Mollie\Api\Http\Requests\ResourceHydratableRequest;
use Mollie\Api\Http\Response;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Resources\AnyResource;
use Mollie\Api\Resources\BaseResource;
use Mollie\Api\Resources\CursorCollection;
use Mollie\Api\Resources\DecorateResource;
use Mollie\Api\Resources\ResourceHydrator;
use Mollie\Api\MollieApiClient;
use Mollie\Api\Resources\AnyResource;
use Mollie\Api\Resources\LazyCollection;
use Mollie\Api\Resources\ResourceCollection;
use Mollie\Api\Resources\ResourceHydrator;
use Mollie\Api\Traits\IsIteratableRequest;
use PHPUnit\Framework\TestCase;

class ResourceHydratorTest extends TestCase
{
private ResourceHydrator $hydrator;

private MollieApiClient $client;

protected function setUp(): void
{
parent::setUp();

$this->hydrator = new ResourceHydrator();
$this->hydrator = new ResourceHydrator;
$this->client = $this->createMock(MollieApiClient::class);
}

Expand Down Expand Up @@ -57,7 +58,8 @@ public function hydrate_collection(): void
$request = $this->createMock(ResourceHydratableRequest::class);
$response = $this->createMock(Response::class);

$mockCollection = new class($this->client, $response) extends ResourceCollection {
$mockCollection = new class($this->client, $response) extends ResourceCollection
{
public static string $resource = AnyResource::class;

public static string $collectionName = 'items';
Expand All @@ -73,9 +75,9 @@ public function hydrate_collection(): void

$response->expects($this->once())
->method('json')
->willReturn((object)[
'_embedded' => (object)['items' => []],
'_links' => (object)[]
->willReturn((object) [
'_embedded' => (object) ['items' => []],
'_links' => (object) [],
]);

$result = $this->hydrator->hydrate($request, $response);
Expand Down Expand Up @@ -106,14 +108,14 @@ public function hydrate_iteratable_collection(): void

$response->expects($this->once())
->method('json')
->willReturn((object)[
'_embedded' => (object)['items' => [
(object)[
->willReturn((object) [
'_embedded' => (object) ['items' => [
(object) [
'id' => 'id',
'foo' => 'bar',
]
],
]],
'_links' => (object)[]
'_links' => (object) [],
]);

$result = $this->hydrator->hydrate($request, $response);
Expand Down Expand Up @@ -187,6 +189,6 @@ class CustomDecorator implements ResourceDecorator
{
public static function fromResource($resource): self
{
return new self();
return new self;
}
}

0 comments on commit b5aac11

Please sign in to comment.