Files
firefly-iii/app/Support/Request/GetRecurrenceData.php

57 lines
1.9 KiB
PHP
Raw Normal View History

2018-02-10 09:57:31 +01:00
<?php
/**
* GetRecurrenceData.php
* Copyright (c) 2020 james@firefly-iii.org
2018-02-10 09:57:31 +01:00
*
* This file is part of Firefly III (https://github.com/firefly-iii).
2018-02-10 09:57:31 +01:00
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
2018-02-10 09:57:31 +01:00
*
* This program is distributed in the hope that it will be useful,
2018-02-10 09:57:31 +01:00
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
2018-02-10 09:57:31 +01:00
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
2018-02-10 09:57:31 +01:00
*/
2018-05-11 10:08:34 +02:00
declare(strict_types=1);
namespace FireflyIII\Support\Request;
2018-03-10 22:38:20 +01:00
2018-02-10 09:57:31 +01:00
/**
* Trait GetRecurrenceData
2018-02-10 09:57:31 +01:00
*/
trait GetRecurrenceData
2018-02-10 09:57:31 +01:00
{
2021-03-14 16:08:49 +01:00
protected function getSingleTransactionData(array $transaction): array
2020-03-19 14:33:41 +01:00
{
2023-12-22 20:12:38 +01:00
$return = [];
$stringKeys = ['id'];
$intKeys = ['currency_id', 'foreign_currency_id', 'source_id', 'destination_id', 'bill_id', 'piggy_bank_id', 'bill_id', 'budget_id', 'category_id'];
$keys = ['amount', 'currency_code', 'foreign_amount', 'foreign_currency_code', 'description', 'tags'];
foreach ($stringKeys as $key) {
if (array_key_exists($key, $transaction)) {
$return[$key] = (string) $transaction[$key];
}
}
foreach ($intKeys as $key) {
if (array_key_exists($key, $transaction)) {
$return[$key] = (int) $transaction[$key];
}
}
foreach ($keys as $key) {
if (array_key_exists($key, $transaction)) {
$return[$key] = $transaction[$key];
}
2021-03-14 16:08:49 +01:00
}
return $return;
2020-03-19 14:33:41 +01:00
}
2018-02-10 09:57:31 +01:00
}