Fix issue with casting.

This commit is contained in:
James Cole 2020-04-19 06:00:11 +02:00
parent fbfd8475de
commit 43436ae942
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
3 changed files with 8 additions and 8 deletions

View File

@ -607,7 +607,7 @@ class TransactionJournalFactory
// validate source account.
$sourceId = isset($data['source_id']) ? (int) $data['source_id'] : null;
$sourceName = $data['source_name'] ?? null;
$sourceName = isset($data['source_name']) ? (string) $data['source_name'] : null;
$validSource = $this->accountValidator->validateSource($sourceId, $sourceName, null);
// do something with result:
@ -617,7 +617,7 @@ class TransactionJournalFactory
Log::debug('Source seems valid.');
// validate destination account
$destinationId = isset($data['destination_id']) ? (int) $data['destination_id'] : null;
$destinationName = (string)($data['destination_name'] ?? null);
$destinationName = isset($data['destination_name']) ? (string) $data['destination_name'] : null;
$validDestination = $this->accountValidator->validateDestination($destinationId, $destinationName, null);
// do something with result:
if (false === $validDestination) {

View File

@ -206,9 +206,9 @@ class ConvertController extends Controller
// double check its not an empty string.
$sourceId = '' === $sourceId || null === $sourceId ? null : (int) $sourceId;
$sourceName = '' === $sourceName ? null : $sourceName;
$sourceName = '' === $sourceName ? null : (string) $sourceName;
$destinationId = '' === $destinationId || null === $destinationId ? null : (int) $destinationId;
$destinationName = (string)('' === $destinationName ? null : $destinationName);
$destinationName = '' === $destinationName ? null : (string) $destinationName;
$validSource = $validator->validateSource($sourceId, $sourceName, null);
$validDestination = $validator->validateDestination($destinationId, $destinationName, null);

View File

@ -73,8 +73,8 @@ trait TransactionValidation
// validate source account.
$sourceId = isset($transaction['source_id']) ? (int) $transaction['source_id'] : null;
$sourceName = $transaction['source_name'] ?? null;
$sourceIban = $transaction['source_iban'] ?? null;
$sourceName = isset($transaction['source_name']) ? (string) $transaction['source_name'] : null;
$sourceIban = isset($transaction['source_iban']) ? (string) $transaction['source_iban'] : null;
$validSource = $accountValidator->validateSource($sourceId, $sourceName, $sourceIban);
// do something with result:
@ -86,8 +86,8 @@ trait TransactionValidation
}
// validate destination account
$destinationId = isset($transaction['destination_id']) ? (int) $transaction['destination_id'] : null;
$destinationName = $transaction['destination_name'] ?? null;
$destinationIban = $transaction['destination_iban'] ?? null;
$destinationName = isset($transaction['destination_name']) ? (string) $transaction['destination_name'] : null;
$destinationIban = isset($transaction['destination_iban']) ? (string) $transaction['destination_iban'] : null;
$validDestination = $accountValidator->validateDestination($destinationId, $destinationName, $destinationIban);
// do something with result:
if (false === $validDestination) {