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 6, 2024
1 parent 8aefdb1 commit 16785c5
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 19 deletions.
6 changes: 3 additions & 3 deletions examples/captures/list-captures.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
$response = $mollie->send(new GetPaginatedPaymentCapturesRequest('tr_WDqYK6vllg'));

foreach ($payment = $response->toResource() as $capture) {
$amount = $capture->amount->currency . ' ' . $capture->amount->value;
echo 'Captured ' . $amount . ' for payment ' . $payment->id;
$amount = $capture->amount->currency.' '.$capture->amount->value;
echo 'Captured '.$amount.' for payment '.$payment->id;
}
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo 'API call failed: ' . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
6 changes: 3 additions & 3 deletions examples/customers/create-customer-first-payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Retrieve the last created customer for this example.
* If no customers are created yet, run the create-customer example.
*/
$customer = $mollie->send(new GetPaginatedCustomerRequest())->toResource()[0];
$customer = $mollie->send(new GetPaginatedCustomerRequest)->toResource()[0];

/*
* Generate a unique order id for this example. It is important to include this unique attribute
Expand Down Expand Up @@ -67,7 +67,7 @@
* After completion, the customer will have a pending or valid mandate that can be
* used for recurring payments and subscriptions.
*/
header('Location: ' . $payment->getCheckoutUrl(), true, 303);
header('Location: '.$payment->getCheckoutUrl(), true, 303);
} catch (\Mollie\Api\Exceptions\ApiException $e) {
echo 'API call failed: ' . htmlspecialchars($e->getMessage());
echo 'API call failed: '.htmlspecialchars($e->getMessage());
}
1 change: 1 addition & 0 deletions src/EndpointCollection/CustomerEndpointCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public function create($data = [], $testmode = []): Customer
* Will throw a ApiException if the customer id is invalid or the resource cannot be found.
*
* @param bool|array $testmode
*
* @throws ApiException
*/
public function get(string $id, $testmode = []): Customer
Expand Down
7 changes: 3 additions & 4 deletions src/Factories/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use Mollie\Api\Contracts\Factory as FactoryContract;
use Mollie\Api\Helpers;
use Mollie\Api\Helpers\Arr;
use Mollie\Api\Http\Payload\DataBag;

abstract class Factory implements FactoryContract
{
Expand All @@ -17,7 +16,7 @@ public function __construct($data)
{
if ($data instanceof Arrayable) {
$this->data = $data->toArray();
} else if ($data instanceof DataProvider) {
} elseif ($data instanceof DataProvider) {
$this->data = $data->data();
} else {
$this->data = $data;
Expand All @@ -41,7 +40,7 @@ protected function get($key, $default = null, $backupKey = 'filters.')
$keys = (array) $key;

if ($backupKey !== null) {
$keys[] = $backupKey . $key;
$keys[] = $backupKey.$key;
}

foreach ($keys as $key) {
Expand All @@ -64,7 +63,7 @@ protected function has($keys): bool
*/
protected function includes($key, $value, $backupKey = 'filters.'): bool
{
return Arr::includes($this->data, [$backupKey . $key, $key], $value);
return Arr::includes($this->data, [$backupKey.$key, $key], $value);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ public static function getProperties($class, $flag = ReflectionProperty::IS_PUBL
public static function filterByProperties($class, array $array): array
{
$properties = array_map(
fn(ReflectionProperty $prop) => $prop->getName(),
fn (ReflectionProperty $prop) => $prop->getName(),
static::getProperties($class)
);

return array_filter(
$array,
fn($key) => ! in_array($key, $properties, true),
fn ($key) => ! in_array($key, $properties, true),
ARRAY_FILTER_USE_KEY
);
}
Expand All @@ -96,7 +96,7 @@ public static function compose($value, $composable, $default = null)
}

$composable = is_string($composable)
? fn($value) => new $composable($value)
? fn ($value) => new $composable($value)
: $composable;

return (bool) $value ? $composable($value) : $default;
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Adapter/GuzzleMollieHttpAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@ protected function createResponse(
*/
public function version(): string
{
return 'Guzzle/' . ClientInterface::MAJOR_VERSION;
return 'Guzzle/'.ClientInterface::MAJOR_VERSION;
}
}
13 changes: 8 additions & 5 deletions tests/Helpers/HelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

use Mollie\Api\Helpers;
use Mollie\Api\Http\Payload\Metadata;
use Tests\TestCase;
use ReflectionProperty;
use Tests\TestCase;

class HelpersTest extends TestCase
{
/** @test */
public function class_uses_recursive()
{
$result = Helpers::classUsesRecursive(new TestChildClass());
$result = Helpers::classUsesRecursive(new TestChildClass);

$this->assertContains(TestTrait1::class, $result);
$this->assertContains(TestTrait2::class, $result);
Expand Down Expand Up @@ -48,7 +48,7 @@ public function filter_by_properties()
$array = [
'prop1' => 'value1',
'prop2' => 'value2',
'extraProp' => 'extraValue'
'extraProp' => 'extraValue',
];

$filtered = Helpers::filterByProperties(TestFilterClass::class, $array);
Expand All @@ -62,15 +62,15 @@ public function filter_by_properties()
public function compose()
{
// Test with callable
$composedWithCallable = Helpers::compose(5, fn($x) => $x * 2);
$composedWithCallable = Helpers::compose(5, fn ($x) => $x * 2);
$this->assertEquals(10, $composedWithCallable);

$composedWithClass = Helpers::compose('test', TestComposable::class);
$this->assertInstanceOf(TestComposable::class, $composedWithClass);
$this->assertEquals('test', $composedWithClass->value);

// Test with falsy value
$composedWithDefault = Helpers::compose(false, fn($x) => $x * 2, 'default');
$composedWithDefault = Helpers::compose(false, fn ($x) => $x * 2, 'default');
$this->assertEquals('default', $composedWithDefault);

$existingValueIsNotOverriden = Helpers::compose(new Metadata(['key' => 'value']), Metadata::class);
Expand Down Expand Up @@ -125,13 +125,16 @@ trait TestTraitMain
class TestPropertiesClass
{
public $publicProp;

protected $protectedProp;

private $privateProp;
}

class TestFilterClass
{
public $prop1;

public $prop2;
}

Expand Down

0 comments on commit 16785c5

Please sign in to comment.