Added PHP7 return type statements.

This commit is contained in:
James Cole 2016-02-06 10:11:06 +01:00
parent c9b56efaaa
commit 466067bd95
12 changed files with 169 additions and 108 deletions

View File

@ -31,7 +31,7 @@ class AccountList implements BinderInterface
* *
* @return Collection * @return Collection
*/ */
public static function routeBinder($value, $route) public static function routeBinder($value, $route): Collection
{ {
if (Auth::check()) { if (Auth::check()) {

View File

@ -12,6 +12,7 @@ namespace FireflyIII\Support\Binder;
use Auth; use Auth;
use FireflyIII\Models\Budget; use FireflyIII\Models\Budget;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
@ -29,7 +30,7 @@ class BudgetList implements BinderInterface
* *
* @return mixed * @return mixed
*/ */
public static function routeBinder($value, $route) public static function routeBinder($value, $route): Collection
{ {
if (Auth::check()) { if (Auth::check()) {
$ids = explode(',', $value); $ids = explode(',', $value);

View File

@ -12,6 +12,7 @@ namespace FireflyIII\Support\Binder;
use Auth; use Auth;
use FireflyIII\Models\Category; use FireflyIII\Models\Category;
use Illuminate\Support\Collection;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@ -28,7 +29,7 @@ class CategoryList implements BinderInterface
* *
* @return mixed * @return mixed
*/ */
public static function routeBinder($value, $route) public static function routeBinder($value, $route): Collection
{ {
if (Auth::check()) { if (Auth::check()) {
$ids = explode(',', $value); $ids = explode(',', $value);

View File

@ -32,7 +32,7 @@ class Date implements BinderInterface
* *
* @return mixed * @return mixed
*/ */
public static function routeBinder($value, $route) public static function routeBinder($value, $route): Carbon
{ {
$fiscalHelper = new FiscalHelper; $fiscalHelper = new FiscalHelper;

View File

@ -18,7 +18,7 @@ class Amount extends Facade
* *
* @return string * @return string
*/ */
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return 'amount'; return 'amount';
} }

View File

@ -18,7 +18,7 @@ class ExpandedForm extends Facade
* *
* @return string * @return string
*/ */
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return 'expandedform'; return 'expandedform';
} }

View File

@ -18,7 +18,7 @@ class Navigation extends Facade
* *
* @return string * @return string
*/ */
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return 'navigation'; return 'navigation';
} }

View File

@ -18,7 +18,7 @@ class Preferences extends Facade
* *
* @return string * @return string
*/ */
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return 'preferences'; return 'preferences';
} }

View File

@ -18,7 +18,7 @@ class Steam extends Facade
* *
* @return string * @return string
*/ */
protected static function getFacadeAccessor() protected static function getFacadeAccessor(): string
{ {
return 'steam'; return 'steam';
} }

View File

@ -43,8 +43,10 @@ class TestData
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createAssetAccounts(User $user) public static function createAssetAccounts(User $user): bool
{ {
$assets = ['TestData Checking Account', 'TestData Savings', 'TestData Shared', 'TestData Creditcard', 'Emergencies', 'STE']; $assets = ['TestData Checking Account', 'TestData Savings', 'TestData Shared', 'TestData Creditcard', 'Emergencies', 'STE'];
// first two ibans match test-upload.csv // first two ibans match test-upload.csv
@ -75,13 +77,17 @@ class TestData
} }
} }
return true;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $start * @param Carbon $start
*
* @return TransactionJournal
*/ */
public static function createAttachments(User $user, Carbon $start) public static function createAttachments(User $user, Carbon $start): TransactionJournal
{ {
$toAccount = TestData::findAccount($user, 'TestData Checking Account'); $toAccount = TestData::findAccount($user, 'TestData Checking Account');
@ -138,12 +144,15 @@ class TestData
file_put_contents(storage_path('upload/at-' . $one->id . '.data'), $encrypted); file_put_contents(storage_path('upload/at-' . $one->id . '.data'), $encrypted);
file_put_contents(storage_path('upload/at-' . $two->id . '.data'), $encrypted); file_put_contents(storage_path('upload/at-' . $two->id . '.data'), $encrypted);
return $journal;
} }
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createBills(User $user) public static function createBills(User $user): bool
{ {
Bill::create( Bill::create(
[ [
@ -174,15 +183,19 @@ class TestData
] ]
); );
return true;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $current * @param Carbon $current
* @param $name * @param string $name
* @param $amount * @param string $amount
*
* @return BudgetLimit
*/ */
public static function createBudgetLimit(User $user, Carbon $current, string $name, string $amount) public static function createBudgetLimit(User $user, Carbon $current, string $name, string $amount): BudgetLimit
{ {
$start = clone $current; $start = clone $current;
$end = clone $current; $end = clone $current;
@ -190,7 +203,7 @@ class TestData
$start->startOfMonth(); $start->startOfMonth();
$end->endOfMonth(); $end->endOfMonth();
BudgetLimit::create( $limit = BudgetLimit::create(
[ [
'budget_id' => $budget->id, 'budget_id' => $budget->id,
'startdate' => $start->format('Y-m-d'), 'startdate' => $start->format('Y-m-d'),
@ -199,12 +212,16 @@ class TestData
'repeat_freq' => 'monthly', 'repeat_freq' => 'monthly',
] ]
); );
return $limit;
} }
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createBudgets(User $user) public static function createBudgets(User $user): bool
{ {
Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); Budget::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]);
Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]); Budget::firstOrCreateEncrypted(['name' => 'Bills', 'user_id' => $user->id]);
@ -214,16 +231,18 @@ class TestData
foreach (['A', 'B', 'C', 'D', "E"] as $letter) { foreach (['A', 'B', 'C', 'D', "E"] as $letter) {
Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]); Budget::firstOrCreateEncrypted(['name' => 'Empty budget ' . $letter, 'user_id' => $user->id]);
} }
return true;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $date * @param Carbon $date
* *
* @return static * @return TransactionJournal
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public static function createCar(User $user, Carbon $date) public static function createCar(User $user, Carbon $date): TransactionJournal
{ {
// twice: // twice:
$date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th $date = new Carbon($date->format('Y-m') . '-10'); // paid on 10th
@ -262,7 +281,7 @@ class TestData
'date' => $date, 'date' => $date,
] ]
); );
self::createTransactions($journal, $fromAccount, $toAccount, '100'); self::createTransactions($journal, $fromAccount, $toAccount, strval($amount));
// and again! // and again!
@ -271,19 +290,26 @@ class TestData
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createCategories(User $user) public static function createCategories(User $user): bool
{ {
Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]); Category::firstOrCreateEncrypted(['name' => 'Groceries', 'user_id' => $user->id]);
Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]); Category::firstOrCreateEncrypted(['name' => 'Car', 'user_id' => $user->id]);
return true;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $date * @param Carbon $date
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public static function createDrinksAndOthers(User $user, Carbon $date) public static function createDrinksAndOthers(User $user, Carbon $date): bool
{ {
$start = clone $date; $start = clone $date;
$end = clone $date; $end = clone $date;
@ -321,15 +347,19 @@ class TestData
$current->addWeek(); $current->addWeek();
} }
return true;
} }
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createExpenseAccounts(User $user) public static function createExpenseAccounts(User $user): bool
{ {
$expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl', $expenses = ['Adobe', 'Google', 'Vitens', 'Albert Heijn', 'PLUS', 'Apple', 'Bakker', 'Belastingdienst', 'bol.com', 'Cafe Central', 'conrad.nl',
'coolblue', 'Shell', 'Coolblue', 'Shell',
'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord']; 'DUO', 'Etos', 'FEBO', 'Greenchoice', 'Halfords', 'XS4All', 'iCentre', 'Jumper', 'Land lord'];
foreach ($expenses as $name) { foreach ($expenses as $name) {
// create account: // create account:
@ -344,14 +374,19 @@ class TestData
); );
} }
return true;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $date * @param Carbon $date
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength) * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public static function createGroceries(User $user, Carbon $date) public static function createGroceries(User $user, Carbon $date): bool
{ {
bcscale(2); bcscale(2);
$start = clone $date; $start = clone $date;
@ -392,6 +427,8 @@ class TestData
$current->addDay(); $current->addDay();
} }
return true;
} }
/** /**
@ -432,10 +469,13 @@ class TestData
} }
/** /**
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @param User $user * @param User $user
*
* @return bool
*
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/ */
public static function createPiggybanks(User $user) public static function createPiggybanks(User $user): bool
{ {
$account = self::findAccount($user, 'TestData Savings'); $account = self::findAccount($user, 'TestData Savings');
@ -567,6 +607,7 @@ class TestData
] ]
); );
return true;
} }
/** /**
@ -577,7 +618,7 @@ class TestData
* *
* @return TransactionJournal * @return TransactionJournal
*/ */
public static function createPower(User $user, string $description, Carbon $date, string $amount) public static function createPower(User $user, string $description, Carbon $date, string $amount): TransactionJournal
{ {
$date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th $date = new Carbon($date->format('Y-m') . '-06'); // paid on 10th
$fromAccount = TestData::findAccount($user, 'TestData Checking Account'); $fromAccount = TestData::findAccount($user, 'TestData Checking Account');
@ -638,8 +679,10 @@ class TestData
/** /**
* @param User $user * @param User $user
*
* @return bool
*/ */
public static function createRevenueAccounts(User $user) public static function createRevenueAccounts(User $user): bool
{ {
$revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google']; $revenues = ['Job', 'Belastingdienst', 'Bank', 'KPN', 'Google'];
foreach ($revenues as $name) { foreach ($revenues as $name) {
@ -654,12 +697,16 @@ class TestData
] ]
); );
} }
return true;
} }
/** /**
* @param User $user * @param User $user
*
* @return RuleGroup
*/ */
public static function createRules(User $user) public static function createRules(User $user): RuleGroup
{ {
$group = RuleGroup::create( $group = RuleGroup::create(
[ [
@ -733,6 +780,8 @@ class TestData
'action_value' => trans('firefly.default_rule_action_set_category'), 'action_value' => trans('firefly.default_rule_action_set_category'),
] ]
); );
return $group;
} }
/** /**
@ -772,9 +821,9 @@ class TestData
* @param Carbon $date * @param Carbon $date
* @param string $amount * @param string $amount
* *
* @return static * @return TransactionJournal
*/ */
public static function createTV(User $user, string $description, Carbon $date, string $amount) public static function createTV(User $user, string $description, Carbon $date, string $amount): TransactionJournal
{ {
$date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th $date = new Carbon($date->format('Y-m') . '-15'); // paid on 10th
$fromAccount = TestData::findAccount($user, 'TestData Checking Account'); $fromAccount = TestData::findAccount($user, 'TestData Checking Account');
@ -801,26 +850,27 @@ class TestData
} }
/** /**
* @param User $user * @param User $user
* @param Carbon|null $date * @param Carbon $date
*
* @return Tag
*/ */
public static function createTags(User $user, Carbon $date = null) public static function createTags(User $user, Carbon $date): Tag
{ {
$title = 'SomeTag nr. ' . rand(1, 1234); $title = 'SomeTag' . $date->month . '.' . $date->year . '.nothing';
if (!is_null($date)) {
$title = 'SomeTag' . $date->month . '.' . $date->year . '.nothing';
}
Tag::create( $tag = Tag::create(
[ [
'user_id' => $user->id, 'user_id' => $user->id,
'tag' => $title, 'tag' => $title,
'tagMode' => 'nothing', 'tagMode' => 'nothing',
'date' => is_null($date) ? null : $date->format('Y-m-d'), 'date' => $date->format('Y-m-d'),
] ]
); );
return $tag;
} }
/** /**
@ -828,8 +878,10 @@ class TestData
* @param Account $from * @param Account $from
* @param Account $to * @param Account $to
* @param string $amount * @param string $amount
*
* @return bool
*/ */
public static function createTransactions(TransactionJournal $journal, Account $from, Account $to, string $amount) public static function createTransactions(TransactionJournal $journal, Account $from, Account $to, string $amount): bool
{ {
Log::debug('---- Transaction From: ' . bcmul($amount, '-1')); Log::debug('---- Transaction From: ' . bcmul($amount, '-1'));
Log::debug('---- Transaction To : ' . $amount); Log::debug('---- Transaction To : ' . $amount);
@ -849,6 +901,8 @@ class TestData
] ]
); );
return true;
} }
/** /**
@ -873,7 +927,7 @@ class TestData
* @param Carbon $date * @param Carbon $date
* @param string $amount * @param string $amount
* *
* @return TransactionJournal|static * @return TransactionJournal
*/ */
public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal public static function createWater(User $user, string $description, Carbon $date, string $amount): TransactionJournal
{ {
@ -922,9 +976,9 @@ class TestData
* @param User $user * @param User $user
* @param $name * @param $name
* *
* @return Budget|null * @return Budget
*/ */
public static function findBudget(User $user, string $name) public static function findBudget(User $user, string $name): Budget
{ {
/** @var Budget $budget */ /** @var Budget $budget */
foreach (Budget::get() as $budget) { foreach (Budget::get() as $budget) {
@ -934,14 +988,16 @@ class TestData
} }
} }
return null; return new Budget;
} }
/** /**
* @param User $user * @param User $user
* @param Carbon $date * @param Carbon $date
*
* @return TransactionJournal
*/ */
public static function openingBalanceSavings(User $user, Carbon $date) public static function openingBalanceSavings(User $user, Carbon $date): TransactionJournal
{ {
// opposing account for opening balance: // opposing account for opening balance:
$opposing = Account::create( $opposing = Account::create(
@ -968,6 +1024,7 @@ class TestData
] ]
); );
self::createTransactions($journal, $opposing, $savings, '10000'); self::createTransactions($journal, $opposing, $savings, '10000');
return $journal;
} }

View File

@ -3,6 +3,8 @@ declare(strict_types = 1);
namespace FireflyIII; namespace FireflyIII;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasManyThrough;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Zizaco\Entrust\Traits\EntrustUserTrait; use Zizaco\Entrust\Traits\EntrustUserTrait;
@ -60,105 +62,105 @@ class User extends Authenticatable
protected $table = 'users'; protected $table = 'users';
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function accounts() public function accounts(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Account'); return $this->hasMany('FireflyIII\Models\Account');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function attachments() public function attachments(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Attachment'); return $this->hasMany('FireflyIII\Models\Attachment');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function bills() public function bills(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Bill'); return $this->hasMany('FireflyIII\Models\Bill');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function budgets() public function budgets(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Budget'); return $this->hasMany('FireflyIII\Models\Budget');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function categories() public function categories(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Category'); return $this->hasMany('FireflyIII\Models\Category');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function exportjobs() public function exportjobs(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\ExportJob'); return $this->hasMany('FireflyIII\Models\ExportJob');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough * @return HasManyThrough
*/ */
public function piggyBanks() public function piggyBanks(): HasManyThrough
{ {
return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account'); return $this->hasManyThrough('FireflyIII\Models\PiggyBank', 'FireflyIII\Models\Account');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function preferences() public function preferences(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Preference'); return $this->hasMany('FireflyIII\Models\Preference');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function ruleGroups() public function ruleGroups(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\RuleGroup'); return $this->hasMany('FireflyIII\Models\RuleGroup');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function rules() public function rules(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Rule'); return $this->hasMany('FireflyIII\Models\Rule');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function tags() public function tags(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\Tag'); return $this->hasMany('FireflyIII\Models\Tag');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function transactionjournals() public function transactionjournals(): HasMany
{ {
return $this->hasMany('FireflyIII\Models\TransactionJournal'); return $this->hasMany('FireflyIII\Models\TransactionJournal');
} }
/** /**
* @return \Illuminate\Database\Eloquent\Relations\HasManyThrough * @return HasManyThrough
*/ */
public function transactions() public function transactions(): HasManyThrough
{ {
return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal'); return $this->hasManyThrough('FireflyIII\Models\Transaction', 'FireflyIII\Models\TransactionJournal');
} }

View File

@ -48,7 +48,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateBelongsToUser($attribute, $value, $parameters) public function validateBelongsToUser($attribute, $value, $parameters): bool
{ {
$field = $parameters[1] ?? 'id'; $field = $parameters[1] ?? 'id';
@ -70,7 +70,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateIban($attribute, $value) public function validateIban($attribute, $value): bool
{ {
if (!is_string($value) || is_null($value) || strlen($value) < 6) { if (!is_string($value) || is_null($value) || strlen($value) < 6) {
return false; return false;
@ -97,7 +97,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateRuleActionValue($attribute) public function validateRuleActionValue($attribute): bool
{ {
// get the index from a string like "rule-action-value.2". // get the index from a string like "rule-action-value.2".
$parts = explode('.', $attribute); $parts = explode('.', $attribute);
@ -139,7 +139,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateRuleTriggerValue($attribute) public function validateRuleTriggerValue($attribute): bool
{ {
// get the index from a string like "rule-trigger-value.2". // get the index from a string like "rule-trigger-value.2".
$parts = explode('.', $attribute); $parts = explode('.', $attribute);
@ -176,7 +176,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateUniqueAccountForUser($attribute, $value, $parameters) public function validateUniqueAccountForUser($attribute, $value, $parameters): bool
{ {
// because a user does not have to be logged in (tests and what-not). // because a user does not have to be logged in (tests and what-not).
if (!Auth::check()) { if (!Auth::check()) {
@ -207,7 +207,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateUniqueForUser($attribute, $value, $parameters) public function validateUniqueForUser($attribute, $value, $parameters): bool
{ {
$query = DB::table($parameters[0])->where($parameters[1], $value); $query = DB::table($parameters[0])->where($parameters[1], $value);
$query->where('user_id', Auth::user()->id); $query->where('user_id', Auth::user()->id);
@ -238,7 +238,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateUniqueObjectForUser($attribute, $value, $parameters) public function validateUniqueObjectForUser($attribute, $value, $parameters): bool
{ {
$value = $this->tryDecrypt($value); $value = $this->tryDecrypt($value);
// exclude? // exclude?
@ -271,9 +271,9 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
public function validateUniquePiggyBankForUser($attribute, $value, $parameters) public function validateUniquePiggyBankForUser($attribute, $value, $parameters): bool
{ {
$exclude = $parameters[0] ?? null; $exclude = $parameters[0] ?? null;
$query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at') $query = DB::table('piggy_banks')->whereNull('piggy_banks.deleted_at')
->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id); ->leftJoin('accounts', 'accounts.id', '=', 'piggy_banks.account_id')->where('accounts.user_id', Auth::user()->id);
if (!is_null($exclude)) { if (!is_null($exclude)) {
@ -292,12 +292,33 @@ class FireflyValidator extends Validator
return true; return true;
} }
/**
* @param int $index
*
* @return string
*/
private function getRuleTriggerName($index): string
{
return $this->data['rule-trigger'][$index] ?? 'invalid';
}
/**
* @param int $index
*
* @return string
*/
private function getRuleTriggerValue($index): string
{
return $this->data['rule-trigger-value'][$index] ?? '';
}
/** /**
* @param $value * @param $value
* *
* @return mixed * @return mixed
*/ */
protected function tryDecrypt($value) private function tryDecrypt($value)
{ {
try { try {
$value = Crypt::decrypt($value); $value = Crypt::decrypt($value);
@ -311,7 +332,7 @@ class FireflyValidator extends Validator
/** /**
* @return bool * @return bool
*/ */
protected function validateAccountAnonymously() private function validateAccountAnonymously(): bool
{ {
if (!isset($this->data['user_id'])) { if (!isset($this->data['user_id'])) {
return false; return false;
@ -340,7 +361,7 @@ class FireflyValidator extends Validator
* @internal param $parameters * @internal param $parameters
* *
*/ */
protected function validateByAccountId($value) private function validateByAccountId($value): bool
{ {
/** @var Account $existingAccount */ /** @var Account $existingAccount */
$existingAccount = Account::find($this->data['id']); $existingAccount = Account::find($this->data['id']);
@ -367,7 +388,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
protected function validateByAccountTypeId($value, $parameters) private function validateByAccountTypeId($value, $parameters): bool
{ {
$type = AccountType::find($this->data['account_type_id'])->first(); $type = AccountType::find($this->data['account_type_id'])->first();
$ignore = $parameters[0] ?? 0; $ignore = $parameters[0] ?? 0;
@ -391,7 +412,7 @@ class FireflyValidator extends Validator
* *
* @return bool * @return bool
*/ */
protected function validateByAccountTypeString($value, $parameters) private function validateByAccountTypeString($value, $parameters): bool
{ {
$search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']); $search = Config::get('firefly.accountTypeByIdentifier.' . $this->data['what']);
$type = AccountType::whereType($search)->first(); $type = AccountType::whereType($search)->first();
@ -407,26 +428,5 @@ class FireflyValidator extends Validator
return true; return true;
} }
/**
* @param int $index
*
* @return string
*/
private function getRuleTriggerName($index)
{
return $this->data['rule-trigger'][$index] ?? 'invalid';
}
/**
* @param int $index
*
* @return string
*/
private function getRuleTriggerValue($index)
{
return $this->data['rule-trigger-value'][$index] ?? '';
}
} }