Various cleanup.

This commit is contained in:
James Cole 2015-01-17 10:06:12 +01:00
parent 0faebc290f
commit 9e2b34bc12
22 changed files with 113 additions and 55 deletions

View File

@ -406,6 +406,8 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $what
*
* @throws NotImplementedException
@ -445,14 +447,14 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
*/
public function firstExpenseAccountOrCreate($name)
{
/** @var \FireflyIII\Database\AccountType\AccountType $accountTypeRepository */
$accountTypeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
/** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
$typeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
$accountType = $accountTypeRepository->findByWhat('expense');
$accountType = $typeRepository->findByWhat('expense');
// if name is "", find cash account:
if (strlen($name) == 0) {
$cashAccountType = $accountTypeRepository->findByWhat('cash');
$cashAccountType = $typeRepository->findByWhat('cash');
// find or create cash account:
return \Account::firstOrCreate(
@ -474,10 +476,10 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
*/
public function firstRevenueAccountOrCreate($name)
{
/** @var \FireflyIII\Database\AccountType\AccountType $accountTypeRepository */
$accountTypeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
/** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
$typeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
$accountType = $accountTypeRepository->findByWhat('revenue');
$accountType = $typeRepository->findByWhat('revenue');
$data = ['user_id' => $this->getUser()->id, 'account_type_id' => $accountType->id, 'name' => $name, 'active' => 1];

View File

@ -19,6 +19,7 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
/**
* @param Eloquent $model
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
* @throws NotImplementedException
@ -30,6 +31,7 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
/**
* @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return \Eloquent
* @throws NotImplementedException
@ -42,6 +44,7 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
/**
* @param Eloquent $model
* @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
* @throws NotImplementedException
@ -52,6 +55,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Validates an array. Returns an array containing MessageBags
* errors/warnings/successes.
*
@ -66,6 +71,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -88,30 +95,22 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
*/
public function findByWhat($what)
{
switch ($what) {
case 'expense':
return \AccountType::whereType('Expense account')->first();
break;
case 'asset':
return \AccountType::whereType('Asset account')->first();
break;
case 'revenue':
return \AccountType::whereType('Revenue account')->first();
break;
case 'cash':
return \AccountType::whereType('Cash account')->first();
break;
case 'initial':
return \AccountType::whereType('Initial balance account')->first();
break;
default:
throw new FireflyException('Cannot find account type described as "' . e($what) . '".');
break;
$typeMap = [
'expense' => 'Expense account',
'asset' => 'Asset account',
'revenue' => 'Revenue account',
'cash' => 'Cash account',
'initial' => 'Initial balance account',
];
if (isset($typeMap[$what])) {
return \AccountType::whereType($typeMap[$what])->first();
}
throw new FireflyException('Cannot find account type described as "' . e($what) . '".');
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns all objects.
*
* @return Collection
@ -123,6 +122,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids
*
* @return Collection

View File

@ -133,6 +133,8 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -146,6 +148,8 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -169,6 +173,7 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @param array $ids
*
* @return Collection
@ -205,15 +210,14 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
}
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param \Bill $bill
*
* @return Carbon|null
*/
public function nextExpectedMatch(\Bill $bill)
{
/*
* The date Firefly tries to find. If this stays null, it's "unknown".
*/
$finalDate = null;
if ($bill->active == 0) {
return $finalDate;
@ -225,10 +229,6 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
*/
$today = \DateKit::addPeriod(new Carbon, $bill->repeat_freq, 0);
/*
* FF3 loops from the $start of the bill, and to make sure
* $skip works, it adds one (for modulo).
*/
$skip = $bill->skip + 1;
$start = \DateKit::startOfPeriod(new Carbon, $bill->repeat_freq);
/*

View File

@ -175,6 +175,8 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -200,6 +202,8 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids
*
* @return Collection

View File

@ -99,6 +99,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -112,6 +114,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -125,6 +129,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns all objects.
*
* @return Collection
@ -135,6 +141,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids
*
* @return Collection

View File

@ -58,6 +58,8 @@ class PiggyBankShared
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -123,6 +125,8 @@ class PiggyBankShared
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param Eloquent $model
* @param array $data
*

View File

@ -17,6 +17,8 @@ class RepeatedExpense extends PiggyBankShared implements CUDInterface, CommonDat
{
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* Based on the piggy bank, the reminder-setting and
* other variables this method tries to divide the piggy bank into equal parts. Each is
* accommodated by a reminder (if everything goes to plan).

View File

@ -22,6 +22,7 @@ class Transaction implements CUDInterface, CommonDatabaseCallsInterface
/**
* @param Eloquent $model
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @return bool
* @throws NotImplementedException
@ -59,6 +60,8 @@ class Transaction implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param Eloquent $model
* @param array $data
*
@ -92,6 +95,8 @@ class Transaction implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -105,6 +110,8 @@ class Transaction implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -129,6 +136,8 @@ class Transaction implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids
*
* @return Collection

View File

@ -89,6 +89,8 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -102,6 +104,8 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what
@ -125,6 +129,8 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $objectIds
* @throws NotImplementedException
*

View File

@ -210,6 +210,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
}
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param array $data
*
* @return array
@ -321,6 +323,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
}
/**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model
*
* @return MessageBag
@ -340,6 +344,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
}
/**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model
*
* @return MessageBag
@ -358,6 +364,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
}
/**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model
*
* @return MessageBag
@ -412,6 +420,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
*
* @param $what

View File

@ -20,6 +20,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param Eloquent $model
*
* @return bool
@ -31,6 +33,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $data
*
* @return \Eloquent
@ -42,6 +46,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param Eloquent $model
* @param array $data
*
@ -54,6 +60,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Validates an array. Returns an array containing MessageBags
* errors/warnings/successes.
*
@ -68,6 +76,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id.
*
* @param int $objectId
@ -104,6 +114,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns all objects.
*
* @return Collection
@ -115,6 +127,8 @@ class TransactionType implements CUDInterface, CommonDatabaseCallsInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids
*
* @return Collection

View File

@ -34,6 +34,8 @@ class PiggyBank
}
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param \TransactionJournal $journal
*
* @throws \FireflyIII\Exception\FireflyException
@ -109,6 +111,8 @@ class PiggyBank
*/
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param \TransactionJournal $journal
* @param int $piggyBankId
*/

View File

@ -81,14 +81,5 @@ class Helper implements HelperInterface
}
/**
* @param $what
*
* @return int
*/
public function getTransactionTypeIdByWhat($what)
{
}
}

View File

@ -22,13 +22,6 @@ interface HelperInterface
*/
public function getAssetAccount($what, Collection $transactions);
/**
* @param $what
*
* @return int
*/
public function getTransactionTypeIdByWhat($what);
/**
* @return Collection
*/

View File

@ -227,6 +227,8 @@ class Report implements ReportInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param Carbon $date
* @param bool $shared
*
@ -354,6 +356,8 @@ class Report implements ReportInterface
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param Carbon $start
* @param Carbon $end
* @param int $limit

View File

@ -80,6 +80,8 @@ class Search
}
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $words
*
* @return Collection

View File

@ -15,6 +15,8 @@ class Reminders
{
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param \Reminder $reminder
*
* @return int
@ -62,6 +64,9 @@ class Reminders
return $reminders;
}
/**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*/
public function updateReminders()
{
/** @var Collection $set */

View File

@ -11,6 +11,8 @@ use Illuminate\Validation\Validator;
class FireflyValidator extends Validator
{
/**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param $attribute
* @param $value
* @param $parameters

View File

@ -1,5 +1,4 @@
<?php
use Carbon\Carbon;
use Watson\Validating\ValidatingTrait;
use \Illuminate\Database\Eloquent\Model as Eloquent;
/**

View File

@ -1,8 +1,5 @@
<?php
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model as Eloquent;
use Illuminate\Database\QueryException;
use Watson\Validating\ValidatingTrait;
/**

View File

@ -1,6 +1,5 @@
<?php
use FireflyIII\Exception\FireflyException;
use Watson\Validating\ValidatingTrait;
use \Illuminate\Database\Eloquent\Model as Eloquent;
/**

View File

@ -9,6 +9,8 @@ use League\FactoryMuffin\Facade as f;
class TestCase extends Illuminate\Foundation\Testing\TestCase
{
/**
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*
* Creates the application.
*
* @return \Symfony\Component\HttpKernel\HttpKernelInterface