Skip to content

Commit

Permalink
PHP-72: Remove illuminate dependencies (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
lighe authored Mar 26, 2024
1 parent 18a3313 commit 09e02f4
Show file tree
Hide file tree
Showing 114 changed files with 855 additions and 1,430 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ jobs:
- lowest
- highest
php-version:
- "7.4"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down Expand Up @@ -75,10 +75,6 @@ jobs:
composer remove guzzlehttp/guzzle --dev
composer run acceptance-tests -- --filter "retrieves merchant accounts"
composer require guzzlehttp/guzzle --dev
composer remove symfony/http-client --dev
composer run acceptance-tests -- --filter "retrieves merchant accounts"
composer require php-http/curl-client --dev
composer remove guzzlehttp/guzzle --dev
composer run acceptance-tests -- --filter "retrieves merchant accounts"
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres
to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.0] - 2024-03-26

### Changed

- Removed Illuminate dependencies
- Removed input validation and `TrueLayer\Exception\ValidationException`
- Minimum PHP version supported is 8.1

## [1.7.0] - 2024-02-13

### Changed
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@

This package simplifies working with the TrueLayer API, by:

1. Handling authentication, including token expiry, invalidation and caching
1. Handling authentication (including token expiry) and caching
2. Signing requests
3. Managing idempotency keys, including retrying on conflicts
4. Retrying failed requests, where it makes sense to do so
5. Validating your data
6. Providing type-hinted methods and classes to work with
5. Providing type-hinted methods and classes to work with

<a name="getting-started"></a>

Expand Down Expand Up @@ -1205,16 +1204,6 @@ Thrown if the request data cannot be json encoded prior to calling the APIs.
\TrueLayer\Exceptions\ApiRequestJsonSerializationException
```

### ValidationException

Thrown if the data you provide to the client library or the API response data is invalid.

```php
\TrueLayer\Exceptions\ValidationException

$e->getErrors(); // Get the validation errors as an array
```

### InvalidArgumentException

Thrown when a provided argument is invalid, for example an invalid beneficiary type
Expand Down
8 changes: 3 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
},
"prefer-stable": true,
"require": {
"php": "^7.4 || ^8.0",
"php": "^8.1",
"ext-json": "*",
"ext-openssl": "*",
"psr/http-client-implementation": "^1.0",
"psr/http-factory-implementation": "*",
"psr/http-message-implementation": "^1.0",
"psr/simple-cache": "^1.0|^2.0|^3.0",
"truelayer/signing": "^0.1.0",
"truelayer/signing": "^1.0.0",
"ramsey/uuid": "^3.7|^4.1",
"illuminate/validation": "^v6.0|^v7.0|^v8.0|^v9.0",
"illuminate/support": "^v6.0|^v7.0|^v8.0|^v9.0",
"illuminate/encryption": "^v6.0|^v7.0|^v8.0|^v9.0",
"nesbot/carbon": "^2.62.1|^3.0.0",
"php-http/discovery": "^1.15.1"
},
"suggest": {
Expand Down
4 changes: 0 additions & 4 deletions src/Entities/AccountIdentifier/AccountIdentifierBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use TrueLayer\Entities\EntityBuilder;
use TrueLayer\Exceptions\InvalidArgumentException;
use TrueLayer\Exceptions\ValidationException;
use TrueLayer\Interfaces\AccountIdentifier\AccountIdentifierBuilderInterface;
use TrueLayer\Interfaces\AccountIdentifier\AccountIdentifierInterface;
use TrueLayer\Interfaces\AccountIdentifier\IbanInterface;
Expand All @@ -16,7 +15,6 @@ final class AccountIdentifierBuilder extends EntityBuilder implements AccountIde
{
/**
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return ScanInterface
*/
Expand All @@ -27,7 +25,6 @@ public function sortCodeAccountNumber(): ScanInterface

/**
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return IbanInterface
*/
Expand All @@ -40,7 +37,6 @@ public function iban(): IbanInterface
* @param mixed[] $data
*
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return AccountIdentifierInterface
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Entities/AccountIdentifier/Bban.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ final class Bban extends Entity implements BbanInterface
'bban',
];

/**
* @var string[]
*/
protected array $rules = [
'bban' => 'required|alpha_num|max:30',
];

/**
* @return string
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Entities/AccountIdentifier/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ final class Iban extends Entity implements IbanInterface
'iban',
];

/**
* @var string[]
*/
protected array $rules = [
'iban' => 'required|alpha_num|max:34|min:4',
];

/**
* @return string
*/
Expand Down
7 changes: 0 additions & 7 deletions src/Entities/AccountIdentifier/Nrb.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ final class Nrb extends Entity implements NrbInterface
'nrb',
];

/**
* @var string[]
*/
protected array $rules = [
'nrb' => 'required|numeric|digits:26',
];

/**
* @return string
*/
Expand Down
8 changes: 0 additions & 8 deletions src/Entities/AccountIdentifier/Scan.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,6 @@ final class Scan extends Entity implements ScanInterface
'account_number',
];

/**
* @var string[]
*/
protected array $rules = [
'sort_code' => 'required|numeric|digits:6',
'account_number' => 'required|numeric|digits:8',
];

/**
* @return string
*/
Expand Down
12 changes: 0 additions & 12 deletions src/Entities/Address.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,6 @@ class Address extends Entity implements AddressInterface
'country_code',
];

/**
* @var string[]
*/
protected array $rules = [
'address_line1' => 'string|required',
'address_line2' => 'string|nullable',
'city' => 'string|required',
'state' => 'string|nullable',
'zip' => 'string|required',
'country_code' => 'string|required',
];

/**
* @return string|null
*/
Expand Down
4 changes: 0 additions & 4 deletions src/Entities/Beneficiary/BeneficiaryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use TrueLayer\Entities\EntityBuilder;
use TrueLayer\Exceptions\InvalidArgumentException;
use TrueLayer\Exceptions\ValidationException;
use TrueLayer\Interfaces\Beneficiary\BeneficiaryBuilderInterface;
use TrueLayer\Interfaces\Beneficiary\BeneficiaryInterface;
use TrueLayer\Interfaces\Beneficiary\ExternalAccountBeneficiaryInterface;
Expand All @@ -17,7 +16,6 @@ final class BeneficiaryBuilder extends EntityBuilder implements BeneficiaryBuild
{
/**
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return ExternalAccountBeneficiaryInterface
*/
Expand All @@ -30,7 +28,6 @@ public function externalAccount(): ExternalAccountBeneficiaryInterface
* @param MerchantAccountInterface|null $merchantAccount
*
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return MerchantBeneficiaryInterface
*/
Expand All @@ -49,7 +46,6 @@ public function merchantAccount(MerchantAccountInterface $merchantAccount = null
* @param mixed[] $data
*
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return BeneficiaryInterface
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Entities/Beneficiary/ExternalAccountBeneficiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use TrueLayer\Entities\Entity;
use TrueLayer\Interfaces\AccountIdentifier\AccountIdentifierInterface;
use TrueLayer\Interfaces\Beneficiary\ExternalAccountBeneficiaryInterface;
use TrueLayer\Validation\ValidType;

final class ExternalAccountBeneficiary extends Entity implements ExternalAccountBeneficiaryInterface
{
Expand Down Expand Up @@ -44,18 +43,6 @@ final class ExternalAccountBeneficiary extends Entity implements ExternalAccount
'type',
];

/**
* @return mixed[]
*/
protected function rules(): array
{
return [
'account_holder_name' => 'nullable|string',
'reference' => 'required|string',
'account_identifier' => ['required', ValidType::of(AccountIdentifierInterface::class)],
];
}

/**
* @return string|null
*/
Expand Down
9 changes: 0 additions & 9 deletions src/Entities/Beneficiary/MerchantBeneficiary.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,6 @@ final class MerchantBeneficiary extends Entity implements MerchantBeneficiaryInt
'type',
];

/**
* @var string[]
*/
protected array $rules = [
'merchant_account_id' => 'required|string',
'account_holder_name' => 'nullable|string',
'reference' => 'nullable|string',
];

/**
* @return string|null
*/
Expand Down
13 changes: 0 additions & 13 deletions src/Entities/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,15 @@

namespace TrueLayer\Entities;

use Illuminate\Contracts\Validation\Factory as ValidatorFactory;
use TrueLayer\Exceptions\InvalidArgumentException;
use TrueLayer\Exceptions\ValidationException;
use TrueLayer\Interfaces\ArrayableInterface;
use TrueLayer\Interfaces\Factories\EntityFactoryInterface;
use TrueLayer\Interfaces\HasAttributesInterface;
use TrueLayer\Traits\ArrayableAttributes;
use TrueLayer\Traits\CastsAttributes;
use TrueLayer\Traits\ValidatesAttributes;

abstract class Entity implements ArrayableInterface, HasAttributesInterface
{
use ValidatesAttributes;
use CastsAttributes;
use ArrayableAttributes;

Expand All @@ -26,30 +22,24 @@ abstract class Entity implements ArrayableInterface, HasAttributesInterface
protected EntityFactoryInterface $entityFactory;

/**
* @param ValidatorFactory $validatorFactory
* @param EntityFactoryInterface $entityFactory
*/
public function __construct(
ValidatorFactory $validatorFactory,
EntityFactoryInterface $entityFactory
) {
$this->validatorFactory = $validatorFactory;
$this->entityFactory = $entityFactory;
}

/**
* @param mixed[] $data
*
* @throws ValidationException
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*
* @return $this
*/
public function fill(array $data): self
{
$data = $this->castData($data);
$this->validateData($data);
$this->setValues($data);

return $this;
Expand All @@ -61,8 +51,6 @@ public function fill(array $data): self
* @param class-string<T> $abstract
* @param mixed[]|null $data
*
* @throws ValidationException
* @throws InvalidArgumentException
* @throws InvalidArgumentException
*
* @return T
Expand All @@ -79,7 +67,6 @@ protected function make(string $abstract, array $data = null)
* @param mixed[]|null $data
*
* @throws InvalidArgumentException
* @throws ValidationException
*
* @return T[]
*/
Expand Down
22 changes: 2 additions & 20 deletions src/Entities/Hpp.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace TrueLayer\Entities;

use Illuminate\Support\Str;
use TrueLayer\Exceptions\ValidationException;
use TrueLayer\Interfaces\HppInterface;
use TrueLayer\Services\Util\Str;

final class Hpp extends Entity implements HppInterface
{
Expand Down Expand Up @@ -58,19 +57,6 @@ final class Hpp extends Entity implements HppInterface
'c_tertiary' => 'tertiary_colour',
];

/**
* @var string[]
*/
protected array $rules = [
'base_url' => 'required|url',
'payment_id' => 'required|string',
'resource_token' => 'required|string',
'return_uri' => 'required|url',
'c_primary' => 'regex:/^([0-9A-F]{3}){1,2}$/i',
'c_secondary' => 'regex:/^([0-9A-F]{3}){1,2}$/i',
'c_tertiary' => 'regex:/^([0-9A-F]{3}){1,2}$/i',
];

/**
* @param string $baseUrl
*
Expand Down Expand Up @@ -212,13 +198,11 @@ public function getTertiaryColour(): ?string
}

/**
* @throws ValidationException
*
* @return string
*/
public function toUrl(): string
{
$params = $this->validate()->toArray();
$params = $this->toArray();
unset($params['base_url']);

return $this->baseUrl . '#' . \http_build_query(
Expand All @@ -227,8 +211,6 @@ public function toUrl(): string
}

/**
* @throws ValidationException
*
* @return string
*/
public function __toString(): string
Expand Down
Loading

0 comments on commit 09e02f4

Please sign in to comment.