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 * @param $what
* *
* @throws NotImplementedException * @throws NotImplementedException
@ -445,14 +447,14 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
*/ */
public function firstExpenseAccountOrCreate($name) public function firstExpenseAccountOrCreate($name)
{ {
/** @var \FireflyIII\Database\AccountType\AccountType $accountTypeRepository */ /** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
$accountTypeRepository = \App::make('FireflyIII\Database\AccountType\AccountType'); $typeRepository = \App::make('FireflyIII\Database\AccountType\AccountType');
$accountType = $accountTypeRepository->findByWhat('expense'); $accountType = $typeRepository->findByWhat('expense');
// if name is "", find cash account: // if name is "", find cash account:
if (strlen($name) == 0) { if (strlen($name) == 0) {
$cashAccountType = $accountTypeRepository->findByWhat('cash'); $cashAccountType = $typeRepository->findByWhat('cash');
// find or create cash account: // find or create cash account:
return \Account::firstOrCreate( return \Account::firstOrCreate(
@ -474,10 +476,10 @@ class Account implements CUDInterface, CommonDatabaseCallsInterface, AccountInte
*/ */
public function firstRevenueAccountOrCreate($name) public function firstRevenueAccountOrCreate($name)
{ {
/** @var \FireflyIII\Database\AccountType\AccountType $accountTypeRepository */ /** @var \FireflyIII\Database\AccountType\AccountType $typeRepository */
$accountTypeRepository = \App::make('FireflyIII\Database\AccountType\AccountType'); $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]; $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 * @param Eloquent $model
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* *
* @return bool * @return bool
* @throws NotImplementedException * @throws NotImplementedException
@ -30,6 +31,7 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
/** /**
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* *
* @return \Eloquent * @return \Eloquent
* @throws NotImplementedException * @throws NotImplementedException
@ -42,6 +44,7 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
/** /**
* @param Eloquent $model * @param Eloquent $model
* @param array $data * @param array $data
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* *
* @return bool * @return bool
* @throws NotImplementedException * @throws NotImplementedException
@ -52,6 +55,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Validates an array. Returns an array containing MessageBags * Validates an array. Returns an array containing MessageBags
* errors/warnings/successes. * errors/warnings/successes.
* *
@ -66,6 +71,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id. * Returns an object with id $id.
* *
* @param int $objectId * @param int $objectId
@ -88,30 +95,22 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
*/ */
public function findByWhat($what) public function findByWhat($what)
{ {
switch ($what) { $typeMap = [
case 'expense': 'expense' => 'Expense account',
return \AccountType::whereType('Expense account')->first(); 'asset' => 'Asset account',
break; 'revenue' => 'Revenue account',
case 'asset': 'cash' => 'Cash account',
return \AccountType::whereType('Asset account')->first(); 'initial' => 'Initial balance account',
break; ];
case 'revenue': if (isset($typeMap[$what])) {
return \AccountType::whereType('Revenue account')->first(); return \AccountType::whereType($typeMap[$what])->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;
} }
throw new FireflyException('Cannot find account type described as "' . e($what) . '".');
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns all objects. * Returns all objects.
* *
* @return Collection * @return Collection
@ -123,6 +122,8 @@ class AccountType implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids * @param array $ids
* *
* @return Collection * @return Collection

View File

@ -133,6 +133,8 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id. * Returns an object with id $id.
* *
* @param int $objectId * @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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what
@ -169,6 +173,7 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @param array $ids * @param array $ids
* *
* @return Collection * @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 * @param \Bill $bill
* *
* @return Carbon|null * @return Carbon|null
*/ */
public function nextExpectedMatch(\Bill $bill) public function nextExpectedMatch(\Bill $bill)
{ {
/*
* The date Firefly tries to find. If this stays null, it's "unknown".
*/
$finalDate = null; $finalDate = null;
if ($bill->active == 0) { if ($bill->active == 0) {
return $finalDate; return $finalDate;
@ -225,10 +229,6 @@ class Bill implements CUDInterface, CommonDatabaseCallsInterface, BillInterface
*/ */
$today = \DateKit::addPeriod(new Carbon, $bill->repeat_freq, 0); $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; $skip = $bill->skip + 1;
$start = \DateKit::startOfPeriod(new Carbon, $bill->repeat_freq); $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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what
@ -200,6 +202,8 @@ class Budget implements CUDInterface, CommonDatabaseCallsInterface, BudgetInterf
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids * @param array $ids
* *
* @return Collection * @return Collection

View File

@ -99,6 +99,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id. * Returns an object with id $id.
* *
* @param int $objectId * @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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what
@ -125,6 +129,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns all objects. * Returns all objects.
* *
* @return Collection * @return Collection
@ -135,6 +141,8 @@ class Category implements CUDInterface, CommonDatabaseCallsInterface
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $ids * @param array $ids
* *
* @return Collection * @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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what
@ -123,6 +125,8 @@ class PiggyBankShared
/** /**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param Eloquent $model * @param Eloquent $model
* @param array $data * @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 * Based on the piggy bank, the reminder-setting and
* other variables this method tries to divide the piggy bank into equal parts. Each is * other variables this method tries to divide the piggy bank into equal parts. Each is
* accommodated by a reminder (if everything goes to plan). * accommodated by a reminder (if everything goes to plan).

View File

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

View File

@ -89,6 +89,8 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* Returns an object with id $id. * Returns an object with id $id.
* *
* @param int $objectId * @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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what
@ -125,6 +129,8 @@ class TransactionCurrency implements TransactionCurrencyInterface, CommonDatabas
} }
/** /**
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*
* @param array $objectIds * @param array $objectIds
* @throws NotImplementedException * @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 * @param array $data
* *
* @return array * @return array
@ -321,6 +323,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
} }
/** /**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model * @param array $model
* *
* @return MessageBag * @return MessageBag
@ -340,6 +344,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
} }
/** /**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model * @param array $model
* *
* @return MessageBag * @return MessageBag
@ -358,6 +364,8 @@ class TransactionJournal implements TransactionJournalInterface, CUDInterface, C
} }
/** /**
* @SuppressWarnings("CamelCase") // I'm fine with this.
*
* @param array $model * @param array $model
* *
* @return MessageBag * @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. * Finds an account type using one of the "$what"'s: expense, asset, revenue, opening, etc.
* *
* @param $what * @param $what

View File

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

View File

@ -34,6 +34,8 @@ class PiggyBank
} }
/** /**
* @SuppressWarnings("CyclomaticComplexity") // It's exactly 5. So I don't mind.
*
* @param \TransactionJournal $journal * @param \TransactionJournal $journal
* *
* @throws \FireflyIII\Exception\FireflyException * @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 \TransactionJournal $journal
* @param int $piggyBankId * @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); public function getAssetAccount($what, Collection $transactions);
/**
* @param $what
*
* @return int
*/
public function getTransactionTypeIdByWhat($what);
/** /**
* @return Collection * @return Collection
*/ */

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,6 +1,5 @@
<?php <?php
use FireflyIII\Exception\FireflyException;
use Watson\Validating\ValidatingTrait; use Watson\Validating\ValidatingTrait;
use \Illuminate\Database\Eloquent\Model as Eloquent; 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 class TestCase extends Illuminate\Foundation\Testing\TestCase
{ {
/** /**
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*
* Creates the application. * Creates the application.
* *
* @return \Symfony\Component\HttpKernel\HttpKernelInterface * @return \Symfony\Component\HttpKernel\HttpKernelInterface