Use PSR-12 code style

This commit is contained in:
James Cole
2022-10-30 14:24:10 +01:00
parent 1667b88dcd
commit 64ff5eed27
28 changed files with 96 additions and 129 deletions

View File

@@ -43,7 +43,8 @@ use Log;
*/
class AccountFactory
{
use AccountServiceTrait, LocationServiceTrait;
use AccountServiceTrait;
use LocationServiceTrait;
protected AccountRepositoryInterface $accountRepository;
protected array $validAssetFields;
@@ -279,7 +280,6 @@ class AccountFactory
*/
private function storeMetaData(Account $account, array $data): void
{
$fields = $this->validFields;
if ($account->accountType->type === AccountType::ASSET) {
$fields = $this->validAssetFields;
@@ -292,7 +292,7 @@ class AccountFactory
$type = $account->accountType->type;
$list = config('firefly.valid_currency_account_types');
if (!in_array($type, $list, true)) {
$pos = array_search('currency_id', $fields);
$pos = array_search('currency_id', $fields, true);
if ($pos !== false) {
unset($fields[$pos]);
}
@@ -399,6 +399,4 @@ class AccountFactory
$this->user = $user;
$this->accountRepository->setUser($user);
}
}

View File

@@ -49,7 +49,6 @@ class AccountMetaFactory
$entry = $account->accountMeta()->where('name', $field)->first();
// must not be an empty string:
if ('' !== $value) {
// 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));
@@ -84,5 +83,4 @@ class AccountMetaFactory
{
return AccountMeta::create($data);
}
}

View File

@@ -77,7 +77,7 @@ class AttachmentFactory
);
$notes = (string) ($data['notes'] ?? '');
if ('' !== $notes) {
$note = new Note;
$note = new Note();
$note->noteable()->associate($attachment);
$note->text = $notes;
$note->save();
@@ -93,5 +93,4 @@ class AttachmentFactory
{
$this->user = $user;
}
}

View File

@@ -37,7 +37,8 @@ use Log;
*/
class BillFactory
{
use BillServiceTrait, CreatesObjectGroups;
use BillServiceTrait;
use CreatesObjectGroups;
private User $user;
@@ -129,7 +130,6 @@ class BillFactory
}
return $bill;
}
/**
@@ -149,5 +149,4 @@ class BillFactory
{
$this->user = $user;
}
}

View File

@@ -83,5 +83,4 @@ class BudgetFactory
{
$this->user = $user;
}
}

View File

@@ -99,5 +99,4 @@ class CategoryFactory
{
$this->user = $user;
}
}

View File

@@ -64,7 +64,6 @@ class PiggyBankFactory
}
return null;
}
/**
@@ -83,7 +82,5 @@ class PiggyBankFactory
public function setUser(User $user): void
{
$this->user = $user;
}
}

View File

@@ -37,8 +37,8 @@ use Log;
*/
class RecurrenceFactory
{
use TransactionTypeTrait, RecurringTransactionTrait;
use TransactionTypeTrait;
use RecurringTransactionTrait;
private MessageBag $errors;
private User $user;
@@ -50,7 +50,7 @@ class RecurrenceFactory
*/
public function __construct()
{
$this->errors = new MessageBag;
$this->errors = new MessageBag();
}
/**
@@ -120,20 +120,17 @@ class RecurrenceFactory
if (array_key_exists('notes', $data['recurrence'])) {
$this->updateNote($recurrence, (string) $data['recurrence']['notes']);
}
$this->createRepetitions($recurrence, $data['repetitions'] ?? []);
try {
$this->createTransactions($recurrence, $data['transactions'] ?? []);
} catch (FireflyException $e) {
Log::error($e->getMessage());
$recurrence->forceDelete();
$message = sprintf('Could not create recurring transaction: %s', $e->getMessage());
$this->errors->add('store', $message);
throw new FireflyException($message, 0, $e);
}
@@ -155,6 +152,4 @@ class RecurrenceFactory
{
$this->user = $user;
}
}

View File

@@ -95,7 +95,7 @@ class TagFactory
$tag = Tag::create($array);
if (null !== $tag && null !== $latitude && null !== $longitude) {
// create location object.
$location = new Location;
$location = new Location();
$location->latitude = $latitude;
$location->longitude = $longitude;
$location->zoom_level = $zoomLevel;
@@ -113,5 +113,4 @@ class TagFactory
{
$this->user = $user;
}
}

View File

@@ -102,7 +102,6 @@ class TransactionFactory
];
try {
$result = Transaction::create($data);
} catch (QueryException $e) {
Log::error(sprintf('Could not create transaction: %s', $e->getMessage()), $data);
Log::error($e->getMessage());

View File

@@ -78,7 +78,7 @@ class TransactionGroupFactory
throw new FireflyException('Created zero transaction journals.');
}
$group = new TransactionGroup;
$group = new TransactionGroup();
$group->user()->associate($this->user);
$group->title = $title;
$group->save();

View File

@@ -106,12 +106,12 @@ class TransactionJournalFactory
$dataObject = new NullArrayObject($data);
Log::debug('Start of TransactionJournalFactory::create()');
$collection = new Collection;
$collection = new Collection();
$transactions = $dataObject['transactions'] ?? [];
if (empty($transactions)) {
Log::error('There are no transactions in the array, the TransactionJournalFactory cannot continue.');
return new Collection;
return new Collection();
}
try {
/** @var array $row */
@@ -312,10 +312,8 @@ class TransactionJournalFactory
unset($dataRow['import_hash_v2'], $dataRow['original_source']);
$json = json_encode($dataRow, JSON_THROW_ON_ERROR);
if (false === $json) {
$json = json_encode((string) microtime(), JSON_THROW_ON_ERROR);
Log::error(sprintf('Could not hash the original row! %s', json_last_error_msg()), $dataRow);
}
$hash = hash('sha256', $json);
Log::debug(sprintf('The hash is: %s', $hash), $dataRow);

View File

@@ -87,5 +87,4 @@ class TransactionJournalMetaFactory
return $entry;
}
}

View File

@@ -40,5 +40,4 @@ class TransactionTypeFactory
{
return TransactionType::whereType(ucfirst($type))->first();
}
}