mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-22 20:16:22 +00:00
Code cleaning stuff.
This commit is contained in:
@@ -49,6 +49,7 @@ class AccountFactory
|
||||
|
||||
/**
|
||||
* AccountFactory constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -103,7 +104,7 @@ class AccountFactory
|
||||
// use default currency:
|
||||
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
}
|
||||
$currency->enabled =true;
|
||||
$currency->enabled = true;
|
||||
$currency->save();
|
||||
|
||||
unset($data['currency_code']);
|
||||
|
@@ -43,6 +43,7 @@ class AccountMetaFactory
|
||||
Log::warning(sprintf('%s should not be instantiated in the TEST environment!', \get_class($this)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
@@ -73,6 +74,7 @@ class AccountMetaFactory
|
||||
// if $data has field and $entry is null, create new one:
|
||||
if (null === $entry) {
|
||||
Log::debug(sprintf('Created meta-field "%s":"%s" for account #%d ("%s") ', $field, $value, $account->id, $account->name));
|
||||
|
||||
return $this->create(['account_id' => $account->id, 'name' => $field, 'data' => $value]);
|
||||
}
|
||||
|
||||
@@ -89,6 +91,7 @@ class AccountMetaFactory
|
||||
} catch (Exception $e) { // @codeCoverageIgnore
|
||||
Log::debug(sprintf('Could not delete entry: %s', $e->getMessage())); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@@ -38,6 +38,9 @@ class BillFactory
|
||||
{
|
||||
use BillServiceTrait;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -48,9 +51,6 @@ class BillFactory
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
@@ -63,7 +63,7 @@ class BillFactory
|
||||
/** @var TransactionCurrency $currency */
|
||||
$currency = $factory->find((int)($data['currency_id'] ?? null), (string)($data['currency_code'] ?? null));
|
||||
|
||||
if(null === $currency) {
|
||||
if (null === $currency) {
|
||||
// use default currency:
|
||||
$currency = app('amount')->getDefaultCurrencyByUser($this->user);
|
||||
}
|
||||
@@ -111,7 +111,7 @@ class BillFactory
|
||||
}
|
||||
|
||||
// then find by name:
|
||||
if (null === $bill && \strlen($billName) > 0) {
|
||||
if (null === $bill && '' !== $billName) {
|
||||
$bill = $this->findByName($billName);
|
||||
}
|
||||
|
||||
|
@@ -34,6 +34,9 @@ use Log;
|
||||
*/
|
||||
class BudgetFactory
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -44,10 +47,6 @@ class BudgetFactory
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
|
||||
/**
|
||||
* @param int|null $budgetId
|
||||
* @param null|string $budgetName
|
||||
|
@@ -34,6 +34,9 @@ use Log;
|
||||
*/
|
||||
class CategoryFactory
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -44,9 +47,6 @@ class CategoryFactory
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
*
|
||||
@@ -94,7 +94,7 @@ class CategoryFactory
|
||||
}
|
||||
}
|
||||
|
||||
if (\strlen($categoryName) > 0) {
|
||||
if ('' !== $categoryName) {
|
||||
$category = $this->findByName($categoryName);
|
||||
if (null !== $category) {
|
||||
return $category;
|
||||
|
@@ -33,6 +33,9 @@ use Log;
|
||||
*/
|
||||
class PiggyBankFactory
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -43,9 +46,6 @@ class PiggyBankFactory
|
||||
}
|
||||
}
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param int|null $piggyBankId
|
||||
* @param null|string $piggyBankName
|
||||
@@ -70,7 +70,7 @@ class PiggyBankFactory
|
||||
}
|
||||
|
||||
// then find by name:
|
||||
if (\strlen($piggyBankName) > 0) {
|
||||
if ('' !== $piggyBankName) {
|
||||
/** @var PiggyBank $piggyBank */
|
||||
$piggyBank = $this->findByName($piggyBankName);
|
||||
if (null !== $piggyBank) {
|
||||
|
@@ -39,6 +39,11 @@ use Log;
|
||||
*/
|
||||
class RecurrenceFactory
|
||||
{
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
use TransactionTypeTrait, TransactionServiceTrait, RecurringTransactionTrait;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
@@ -49,11 +54,6 @@ class RecurrenceFactory
|
||||
}
|
||||
}
|
||||
|
||||
use TransactionTypeTrait, TransactionServiceTrait, RecurringTransactionTrait;
|
||||
|
||||
/** @var User */
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
|
@@ -38,6 +38,7 @@ class TransactionCurrencyFactory
|
||||
{
|
||||
/**
|
||||
* TransactionCurrencyFactory constructor.
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __construct()
|
||||
@@ -100,7 +101,7 @@ class TransactionCurrencyFactory
|
||||
Log::warning(sprintf('Currency ID is %d but found nothing!', $currencyId));
|
||||
}
|
||||
// then by code:
|
||||
if (\strlen($currencyCode) > 0) {
|
||||
if ('' !== $currencyCode) {
|
||||
$currency = TransactionCurrency::whereCode($currencyCode)->first();
|
||||
if (null !== $currency) {
|
||||
return $currency;
|
||||
|
@@ -115,7 +115,7 @@ class TransactionFactory
|
||||
$currency = $currency ?? $defaultCurrency;
|
||||
|
||||
// enable currency:
|
||||
if(false === $currency->enabled) {
|
||||
if (false === $currency->enabled) {
|
||||
$currency->enabled = true;
|
||||
$currency->save();
|
||||
}
|
||||
|
@@ -72,9 +72,9 @@ class TransactionJournalFactory
|
||||
$description = app('steam')->cleanString($data['description']);
|
||||
$description = str_replace(["\n", "\t", "\r"], "\x20", $description);
|
||||
/** @var Carbon $carbon */
|
||||
$carbon = $data['date'];
|
||||
$carbon = $data['date'];
|
||||
$carbon->setTimezone(config('app.timezone'));
|
||||
|
||||
|
||||
$journal = TransactionJournal::create(
|
||||
[
|
||||
'user_id' => $data['user'],
|
||||
|
@@ -27,6 +27,7 @@ namespace FireflyIII\Factory;
|
||||
|
||||
use FireflyIII\Models\TransactionType;
|
||||
use Log;
|
||||
|
||||
/**
|
||||
* Class TransactionTypeFactory
|
||||
*/
|
||||
|
Reference in New Issue
Block a user