chore: reformat code.

This commit is contained in:
James Cole
2023-06-21 12:34:58 +02:00
parent 8d87abde64
commit 3dcb35710b
799 changed files with 23319 additions and 22173 deletions

View File

@@ -35,7 +35,7 @@ class ChartJsGenerator implements GeneratorInterface
*
* key => [value => x, 'currency_symbol' => 'x']
*
* @param array $data
* @param array $data
*
* @return array
*/
@@ -100,7 +100,7 @@ class ChartJsGenerator implements GeneratorInterface
*
* // it's five.
*
* @param array $data
* @param array $data
*
* @return array
*/
@@ -149,7 +149,7 @@ class ChartJsGenerator implements GeneratorInterface
*
* key => value
*
* @param array $data
* @param array $data
*
* @return array
*/
@@ -190,8 +190,8 @@ class ChartJsGenerator implements GeneratorInterface
*
* 'label-of-entry' => value
*
* @param string $setLabel
* @param array $data
* @param string $setLabel
* @param array $data
*
* @return array
*/

View File

@@ -29,7 +29,7 @@ namespace FireflyIII\Generator\Chart\Basic;
interface GeneratorInterface
{
/**
* @param array $data
* @param array $data
*
* @return array
*/
@@ -63,7 +63,7 @@ interface GeneratorInterface
*
* // it's five.
*
* @param array $data
* @param array $data
*
* @return array
*/
@@ -74,7 +74,7 @@ interface GeneratorInterface
*
* key => value
*
* @param array $data
* @param array $data
*
* @return array
*/
@@ -85,8 +85,8 @@ interface GeneratorInterface
*
* 'label-of-entry' => value
*
* @param string $setLabel
* @param array $data
* @param string $setLabel
* @param array $data
*
* @return array
*/

View File

@@ -44,6 +44,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Generate the report.
*
* @return string
* @throws FireflyException
*/
@@ -68,10 +69,20 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $result;
}
/**
* Return the preferred period.
*
* @return string
*/
protected function preferredPeriod(): string
{
return 'day';
}
/**
* Set accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -85,7 +96,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set budgets.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -97,7 +108,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set categories.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -109,7 +120,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set end date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -123,7 +134,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set expense collection.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -137,7 +148,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set start date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -151,7 +162,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set collection of tags.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
@@ -159,14 +170,4 @@ class MonthReportGenerator implements ReportGeneratorInterface
{
return $this;
}
/**
* Return the preferred period.
*
* @return string
*/
protected function preferredPeriod(): string
{
return 'day';
}
}

View File

@@ -110,8 +110,8 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Get the audit report.
*
* @param Account $account
* @param Carbon $date
* @param Account $account
* @param Carbon $date
*
* @return array
* @throws FireflyException
@@ -182,7 +182,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Account collection setter.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -196,7 +196,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Budget collection setter.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -208,7 +208,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Category collection setter.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -220,7 +220,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* End date setter.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -234,7 +234,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Expenses collection setter.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -247,7 +247,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Start date collection setter.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -261,7 +261,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Tags collection setter.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -82,38 +82,10 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $result;
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Set the involved budgets.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
$this->budgets = $budgets;
return $this;
}
/**
* Unused category setter.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -125,7 +97,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -139,7 +111,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused expense setter.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -151,7 +123,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -165,7 +137,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused tags setter.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
@@ -200,4 +172,32 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $journals;
}
/**
* Set the involved budgets.
*
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
public function setBudgets(Collection $budgets): ReportGeneratorInterface
{
$this->budgets = $budgets;
return $this;
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
}

View File

@@ -82,24 +82,10 @@ class MonthReportGenerator implements ReportGeneratorInterface
}
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Empty budget setter.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -108,24 +94,10 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $this;
}
/**
* Set the categories involved in this report.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
$this->categories = $categories;
return $this;
}
/**
* Set the end date for this report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -139,7 +111,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses involved in this report.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -151,7 +123,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date for this report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -165,7 +137,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused tag setter.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/
@@ -199,6 +171,34 @@ class MonthReportGenerator implements ReportGeneratorInterface
return $transactions;
}
/**
* Set the categories involved in this report.
*
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
public function setCategories(Collection $categories): ReportGeneratorInterface
{
$this->categories = $categories;
return $this;
}
/**
* Set the involved accounts.
*
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
public function setAccounts(Collection $accounts): ReportGeneratorInterface
{
$this->accounts = $accounts;
return $this;
}
/**
* Get the income for this report.
*

View File

@@ -36,9 +36,9 @@ class ReportGeneratorFactory
/**
* Static report generator class.
*
* @param string $type
* @param Carbon $start
* @param Carbon $end
* @param string $type
* @param Carbon $start
* @param Carbon $end
*
* @return ReportGeneratorInterface
*

View File

@@ -41,7 +41,7 @@ interface ReportGeneratorInterface
/**
* Set the involved accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -50,7 +50,7 @@ interface ReportGeneratorInterface
/**
* Set the involved budgets.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -59,7 +59,7 @@ interface ReportGeneratorInterface
/**
* Set the involved categories.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -68,7 +68,7 @@ interface ReportGeneratorInterface
/**
* Set the end date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -77,7 +77,7 @@ interface ReportGeneratorInterface
/**
* Set the expense accounts.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -86,7 +86,7 @@ interface ReportGeneratorInterface
/**
* Set the start date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -95,7 +95,7 @@ interface ReportGeneratorInterface
/**
* Set the tags.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -67,7 +67,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Sets the accounts involved in the report.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -81,7 +81,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -93,7 +93,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused category setter.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -105,7 +105,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -119,7 +119,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses used in this report.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -131,7 +131,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of this report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -145,7 +145,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the tags used in this report.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -71,7 +71,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the accounts used in the report.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -85,7 +85,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the budgets used in the report.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -97,7 +97,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the categories used in the report.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -109,7 +109,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Sets the end date used in the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -123,7 +123,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Unused setter for expenses.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -135,7 +135,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Set the start date of the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -149,7 +149,7 @@ class MultiYearReportGenerator implements ReportGeneratorInterface
/**
* Set the tags for the report.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -73,7 +73,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -87,7 +87,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -99,7 +99,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused categories setter.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -111,7 +111,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the end date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -125,7 +125,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses used.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -137,7 +137,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Set the start date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -151,7 +151,7 @@ class YearReportGenerator implements ReportGeneratorInterface
/**
* Unused tags setter.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -81,7 +81,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the accounts.
*
* @param Collection $accounts
* @param Collection $accounts
*
* @return ReportGeneratorInterface
*/
@@ -95,7 +95,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused budget setter.
*
* @param Collection $budgets
* @param Collection $budgets
*
* @return ReportGeneratorInterface
*/
@@ -107,7 +107,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Unused category setter.
*
* @param Collection $categories
* @param Collection $categories
*
* @return ReportGeneratorInterface
*/
@@ -119,7 +119,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the end date of the report.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -133,7 +133,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the expenses in this report.
*
* @param Collection $expense
* @param Collection $expense
*
* @return ReportGeneratorInterface
*/
@@ -145,7 +145,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the start date.
*
* @param Carbon $date
* @param Carbon $date
*
* @return ReportGeneratorInterface
*/
@@ -159,7 +159,7 @@ class MonthReportGenerator implements ReportGeneratorInterface
/**
* Set the tags used in this report.
*
* @param Collection $tags
* @param Collection $tags
*
* @return ReportGeneratorInterface
*/

View File

@@ -42,22 +42,22 @@ interface MessageGeneratorInterface
public function getVersion(): int;
/**
* @param Collection $objects
* @param Collection $objects
*/
public function setObjects(Collection $objects): void;
/**
* @param int $trigger
* @param int $trigger
*/
public function setTrigger(int $trigger): void;
/**
* @param User $user
* @param User $user
*/
public function setUser(User $user): void;
/**
* @param Collection $webhooks
* @param Collection $webhooks
* @return void
*/
public function setWebhooks(Collection $webhooks): void;

View File

@@ -81,67 +81,43 @@ class StandardMessageGenerator implements MessageGeneratorInterface
}
/**
* @inheritDoc
*/
public function getVersion(): int
{
return $this->version;
}
/**
* @param Collection $objects
*/
public function setObjects(Collection $objects): void
{
$this->objects = $objects;
}
/**
* @param int $trigger
*/
public function setTrigger(int $trigger): void
{
$this->trigger = $trigger;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
/**
* @inheritDoc
*/
public function setWebhooks(Collection $webhooks): void
{
$this->webhooks = $webhooks;
}
/**
* @param TransactionGroup $transactionGroup
*
* @return Collection
*/
private function collectAccounts(TransactionGroup $transactionGroup): Collection
private function getWebhooks(): Collection
{
$accounts = new Collection();
/** @var TransactionJournal $journal */
foreach ($transactionGroup->transactionJournals as $journal) {
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
$accounts->push($transaction->account);
}
}
return $accounts->unique();
return $this->user->webhooks()->where('active', true)->where('trigger', $this->trigger)->get(['webhooks.*']);
}
/**
* @param Webhook $webhook
* @param Model $model
*
*/
private function run(): void
{
Log::debug('Now in StandardMessageGenerator::run');
/** @var Webhook $webhook */
foreach ($this->webhooks as $webhook) {
$this->runWebhook($webhook);
}
Log::debug('Done with StandardMessageGenerator::run');
}
/**
* @param Webhook $webhook
* @throws FireflyException
* @throws JsonException
*/
private function runWebhook(Webhook $webhook): void
{
Log::debug(sprintf('Now in runWebhook(#%d)', $webhook->id));
/** @var Model $object */
foreach ($this->objects as $object) {
$this->generateMessage($webhook, $object);
}
}
/**
* @param Webhook $webhook
* @param Model $model
* @throws FireflyException
* @throws JsonException
*/
@@ -212,43 +188,35 @@ class StandardMessageGenerator implements MessageGeneratorInterface
}
/**
* @inheritDoc
*/
public function getVersion(): int
{
return $this->version;
}
/**
* @param TransactionGroup $transactionGroup
*
* @return Collection
*/
private function getWebhooks(): Collection
private function collectAccounts(TransactionGroup $transactionGroup): Collection
{
return $this->user->webhooks()->where('active', true)->where('trigger', $this->trigger)->get(['webhooks.*']);
}
/**
*
*/
private function run(): void
{
Log::debug('Now in StandardMessageGenerator::run');
/** @var Webhook $webhook */
foreach ($this->webhooks as $webhook) {
$this->runWebhook($webhook);
$accounts = new Collection();
/** @var TransactionJournal $journal */
foreach ($transactionGroup->transactionJournals as $journal) {
/** @var Transaction $transaction */
foreach ($journal->transactions as $transaction) {
$accounts->push($transaction->account);
}
}
Log::debug('Done with StandardMessageGenerator::run');
return $accounts->unique();
}
/**
* @param Webhook $webhook
* @throws FireflyException
* @throws JsonException
*/
private function runWebhook(Webhook $webhook): void
{
Log::debug(sprintf('Now in runWebhook(#%d)', $webhook->id));
/** @var Model $object */
foreach ($this->objects as $object) {
$this->generateMessage($webhook, $object);
}
}
/**
* @param Webhook $webhook
* @param array $message
* @param Webhook $webhook
* @param array $message
*
* @return void
*/
@@ -263,4 +231,36 @@ class StandardMessageGenerator implements MessageGeneratorInterface
$webhookMessage->save();
Log::debug(sprintf('Stored new webhook message #%d', $webhookMessage->id));
}
/**
* @param Collection $objects
*/
public function setObjects(Collection $objects): void
{
$this->objects = $objects;
}
/**
* @param int $trigger
*/
public function setTrigger(int $trigger): void
{
$this->trigger = $trigger;
}
/**
* @param User $user
*/
public function setUser(User $user): void
{
$this->user = $user;
}
/**
* @inheritDoc
*/
public function setWebhooks(Collection $webhooks): void
{
$this->webhooks = $webhooks;
}
}