diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 3472f87..2634ffc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -13,7 +13,7 @@ parameters: path: src/ApiClient.php - - message: '#^Parameter \#1 \$data of class AssoConnect\\LinxoClient\\Dto\\TransactionDto constructor expects array\{id\: string, account_id\: string, amount\: array\{amount\: string, currency\: string\}, enrichments\: array\{display_label\?\: string, date\: string\}, notes\?\: string, type\?\: string\}, array given\.$#' + message: '#^Parameter \#1 \$data of class AssoConnect\\LinxoClient\\Dto\\TransactionDto constructor expects array\{id\: string, account_id\: string, amount\: array\{amount\: string, currency\: string\}, enrichments\: array\{display_label\?\: string, date\: string, notes\?\: string\}, type\?\: string\}, array given\.$#' identifier: argument.type count: 1 path: src/ApiClient.php @@ -67,7 +67,7 @@ parameters: path: tests/Dto/TransactionDtoTest.php - - message: '#^Parameter \#1 \$data of class AssoConnect\\LinxoClient\\Dto\\TransactionDto constructor expects array\{id\: string, account_id\: string, amount\: array\{amount\: string, currency\: string\}, enrichments\: array\{display_label\?\: string, date\: string\}, notes\?\: string, type\?\: string\}, array\ given\.$#' + message: '#^Parameter \#1 \$data of class AssoConnect\\LinxoClient\\Dto\\TransactionDto constructor expects array\{id\: string, account_id\: string, amount\: array\{amount\: string, currency\: string\}, enrichments\: array\{display_label\?\: string, date\: string, notes\?\: string\}, type\?\: string\}, array\ given\.$#' identifier: argument.type count: 11 path: tests/Dto/TransactionDtoTest.php diff --git a/src/Dto/TransactionDto.php b/src/Dto/TransactionDto.php index c9a2cce..4cb81a5 100644 --- a/src/Dto/TransactionDto.php +++ b/src/Dto/TransactionDto.php @@ -13,8 +13,7 @@ * id: string, * account_id: string, * amount: array{amount: string, currency: string}, - * enrichments: array{display_label?: string, date: string}, - * notes?: string, + * enrichments: array{display_label?: string, date: string, notes?: string}, * type?: string * } */ @@ -70,7 +69,7 @@ public function __construct(array $data) new Currency($currencyCode) ); $this->label = $data['enrichments']['display_label'] ?? null; - $this->notes = $data['notes'] ?? null; + $this->notes = $data['enrichments']['notes'] ?? null; $this->type = $data['type'] ?? self::TYPE_OTHER; $this->date = AbsoluteDate::createInTimezone( // Linxo uses timestamps but their servers' timezone is Europe/Paris diff --git a/tests/Dto/TransactionDtoTest.php b/tests/Dto/TransactionDtoTest.php index b9ecf4f..e83eea3 100644 --- a/tests/Dto/TransactionDtoTest.php +++ b/tests/Dto/TransactionDtoTest.php @@ -24,8 +24,8 @@ public function testConstructorSetsAllProperties(): void 'enrichments' => [ 'display_label' => 'Grocery Store Purchase', 'date' => '2024-03-15T10:30:00+01:00', + 'notes' => 'Weekly groceries', ], - 'notes' => 'Weekly groceries', 'type' => TransactionDto::TYPE_POINT_OF_SALE, ]; @@ -112,7 +112,7 @@ public function testLabelIsNullWhenNotProvided(): void public function testNotesIsNullWhenNotProvided(): void { $data = $this->createBaseData(); - unset($data['notes']); + unset($data['enrichments']['notes']); $dto = new TransactionDto($data); @@ -218,8 +218,8 @@ private function createBaseData(array $overrides = []): array 'enrichments' => [ 'display_label' => 'Test Transaction', 'date' => '2024-03-15T10:00:00+01:00', + 'notes' => 'Test notes', ], - 'notes' => 'Test notes', 'type' => TransactionDto::TYPE_CREDIT, ];