Clean up code, remove unused methods.

This commit is contained in:
James Cole
2018-07-22 16:35:46 +02:00
parent dbbf0ff5e4
commit a722dc4235
43 changed files with 210 additions and 566 deletions

View File

@@ -43,6 +43,7 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
* @property int $order
* @property bool $active
* @property int $account_id
* @property bool encrypted
*
*/
class PiggyBank extends Model
@@ -101,28 +102,6 @@ class PiggyBank extends Model
return $this->belongsTo(Account::class);
}
/**
* Grabs the PiggyBankRepetition that's currently relevant / active.
*
* @deprecated
* @returns PiggyBankRepetition
*/
public function currentRelevantRep(): PiggyBankRepetition
{
if (null !== $this->currentRep) {
return $this->currentRep;
}
// repeating piggy banks are no longer supported.
/** @var PiggyBankRepetition $rep */
$rep = $this->piggyBankRepetitions()->first(['piggy_bank_repetitions.*']);
if (null === $rep) {
return new PiggyBankRepetition();
}
$this->currentRep = $rep;
return $rep;
}
/**
* @codeCoverageIgnore
*
@@ -131,7 +110,7 @@ class PiggyBank extends Model
* @return string
* @throws \Illuminate\Contracts\Encryption\DecryptException
*/
public function getNameAttribute($value)
public function getNameAttribute($value): string
{
if ($this->encrypted) {
return Crypt::decrypt($value);
@@ -140,25 +119,6 @@ class PiggyBank extends Model
return $value;
}
/**
* @param Carbon $date
*
* @deprecated
* @return string
*/
public function leftOnAccount(Carbon $date): string
{
$balance = app('steam')->balanceIgnoreVirtual($this->account, $date);
/** @var PiggyBank $piggyBank */
foreach ($this->account->piggyBanks as $piggyBank) {
$currentAmount = $piggyBank->currentRelevantRep()->currentamount ?? '0';
$balance = bcsub($balance, $currentAmount);
}
return $balance;
}
/**
* @codeCoverageIgnore
* Get all of the piggy bank's notes.
@@ -172,7 +132,7 @@ class PiggyBank extends Model
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankEvents()
public function piggyBankEvents(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(PiggyBankEvent::class);
}
@@ -181,7 +141,7 @@ class PiggyBank extends Model
* @codeCoverageIgnore
* @return \Illuminate\Database\Eloquent\Relations\HasMany
*/
public function piggyBankRepetitions()
public function piggyBankRepetitions(): \Illuminate\Database\Eloquent\Relations\HasMany
{
return $this->hasMany(PiggyBankRepetition::class);
}
@@ -193,7 +153,7 @@ class PiggyBank extends Model
*
* @throws \Illuminate\Contracts\Encryption\EncryptException
*/
public function setNameAttribute($value)
public function setNameAttribute($value): void
{
$encrypt = config('firefly.encryption');
$this->attributes['name'] = $encrypt ? Crypt::encrypt($value) : $value;
@@ -205,7 +165,7 @@ class PiggyBank extends Model
*
* @param $value
*/
public function setTargetamountAttribute($value)
public function setTargetamountAttribute($value): void
{
$this->attributes['targetamount'] = (string)$value;
}