diff --git a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php index 8580bbf1b2..e4dd7a6857 100644 --- a/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php +++ b/app/Generator/Chart/Bill/ChartJsBillChartGenerator.php @@ -24,25 +24,19 @@ class ChartJsBillChartGenerator implements BillChartGenerator */ public function frontpage(Collection $paid, Collection $unpaid) { - - // loop paid and create single entry: $paidDescriptions = []; $paidAmount = 0; $unpaidDescriptions = []; $unpaidAmount = 0; - bcscale(2); /** @var TransactionJournal $entry */ - foreach ($paid as $entry) { - + foreach ($paid as $entry) { // loop paid and create single entry: $paidDescriptions[] = $entry->description; $paidAmount = bcadd($paidAmount, $entry->amount); } - - // loop unpaid: /** @var Bill $entry */ - foreach ($unpaid as $entry) { + foreach ($unpaid as $entry) { // loop unpaid: $description = $entry[0]->name . ' (' . $entry[1]->format('jS M Y') . ')'; $amount = ($entry[0]->amount_max + $entry[0]->amount_min) / 2; $unpaidDescriptions[] = $description; diff --git a/app/Helpers/Csv/Converter/RabobankDebetCredit.php b/app/Helpers/Csv/Converter/RabobankDebetCredit.php index f410c03d92..bfe1babc5e 100644 --- a/app/Helpers/Csv/Converter/RabobankDebetCredit.php +++ b/app/Helpers/Csv/Converter/RabobankDebetCredit.php @@ -3,6 +3,11 @@ namespace FireflyIII\Helpers\Csv\Converter; +/** + * Class RabobankDebetCredit + * + * @package FireflyIII\Helpers\Csv\Converter + */ class RabobankDebetCredit extends BasicConverter implements ConverterInterface { diff --git a/app/Helpers/Csv/Data.php b/app/Helpers/Csv/Data.php index 3230a346e6..f6eca2f145 100644 --- a/app/Helpers/Csv/Data.php +++ b/app/Helpers/Csv/Data.php @@ -119,7 +119,7 @@ class Data /** * @return bool */ - public function getHasHeaders() + public function hasHeaders() { return $this->hasHeaders; } diff --git a/app/Helpers/Csv/Importer.php b/app/Helpers/Csv/Importer.php index 178048deb5..fe8ca0f7dc 100644 --- a/app/Helpers/Csv/Importer.php +++ b/app/Helpers/Csv/Importer.php @@ -107,7 +107,7 @@ class Importer */ protected function parseRow($index) { - return (($this->data->getHasHeaders() && $index > 1) || !$this->data->getHasHeaders()); + return (($this->data->hasHeaders() && $index > 1) || !$this->data->hasHeaders()); } /** diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php index bf3b920568..55d3b67ea4 100644 --- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php +++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php @@ -24,26 +24,20 @@ class OpposingAccount implements PostProcessorInterface */ public function process() { - // first priority. try to find the account based on ID, if any. - if ($this->data['opposing-account-id'] instanceof Account) { + if ($this->data['opposing-account-id'] instanceof Account) { // first priority. try to find the account based on ID, if any $this->data['opposing-account-object'] = $this->data['opposing-account-id']; return $this->data; } - - // second: try to find the account based on IBAN, if any. - if ($this->data['opposing-account-iban'] instanceof Account) { + if ($this->data['opposing-account-iban'] instanceof Account) { // second: try to find the account based on IBAN, if any. $this->data['opposing-account-object'] = $this->data['opposing-account-iban']; return $this->data; } - $rules = ['iban' => 'iban']; $check = ['iban' => $this->data['opposing-account-iban']]; $validator = Validator::make($check, $rules); $result = !$validator->fails(); - - if (is_string($this->data['opposing-account-iban']) && strlen($this->data['opposing-account-iban']) > 0) { if ($result) { $this->data['opposing-account-object'] = $this->parseIbanString(); @@ -51,14 +45,11 @@ class OpposingAccount implements PostProcessorInterface return $this->data; } } - - // third: try to find account based on name, if any. - if ($this->data['opposing-account-name'] instanceof Account) { + if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any. $this->data['opposing-account-object'] = $this->data['opposing-account-name']; return $this->data; } - if (is_string($this->data['opposing-account-name'])) { $this->data['opposing-account-object'] = $this->parseNameString(); diff --git a/app/Helpers/Report/ReportHelper.php b/app/Helpers/Report/ReportHelper.php index 37222d4123..691189df68 100644 --- a/app/Helpers/Report/ReportHelper.php +++ b/app/Helpers/Report/ReportHelper.php @@ -202,11 +202,10 @@ class ReportHelper implements ReportHelperInterface * * @param Carbon $start * @param Carbon $end - * @param boolean $shared * * @return BillCollection */ - public function getBillReport(Carbon $start, Carbon $end, $shared) + public function getBillReport(Carbon $start, Carbon $end) { /** @var \FireflyIII\Repositories\Bill\BillRepositoryInterface $repository */ $repository = App::make('FireflyIII\Repositories\Bill\BillRepositoryInterface'); diff --git a/app/Helpers/Report/ReportHelperInterface.php b/app/Helpers/Report/ReportHelperInterface.php index 75ffbdfd0c..f3dbf42546 100644 --- a/app/Helpers/Report/ReportHelperInterface.php +++ b/app/Helpers/Report/ReportHelperInterface.php @@ -37,11 +37,10 @@ interface ReportHelperInterface * * @param Carbon $start * @param Carbon $end - * @param boolean $shared * * @return BillCollection */ - public function getBillReport(Carbon $start, Carbon $end, $shared); + public function getBillReport(Carbon $start, Carbon $end); /** * @param Carbon $start diff --git a/app/Http/Controllers/Chart/CategoryController.php b/app/Http/Controllers/Chart/CategoryController.php index 28f4f17bf5..917bb76b08 100644 --- a/app/Http/Controllers/Chart/CategoryController.php +++ b/app/Http/Controllers/Chart/CategoryController.php @@ -176,9 +176,7 @@ class CategoryController extends Controller $start = new Carbon($year . '-01-01'); $end = new Carbon($year . '-12-31'); - - // chart properties for cache: - $cache = new CacheProperties; + $cache = new CacheProperties; // chart properties for cache: $cache->addProperty($start); $cache->addProperty($end); $cache->addProperty('category'); @@ -192,14 +190,11 @@ class CategoryController extends Controller $entries = new Collection; while ($start < $end) { - // month is the current end of the period: - $month = clone $start; + $month = clone $start; // month is the current end of the period $month->endOfMonth(); - // make a row: - $row = [clone $start]; + $row = [clone $start]; // make a row: - // each budget, fill the row: - foreach ($categories as $category) { + foreach ($categories as $category) { // each budget, fill the row $spent = $repository->spentInPeriodCorrected($category, $start, $month, $shared); $row[] = $spent; } diff --git a/app/Http/Controllers/CsvController.php b/app/Http/Controllers/CsvController.php index 2f2ece6fad..6349b0a47a 100644 --- a/app/Http/Controllers/CsvController.php +++ b/app/Http/Controllers/CsvController.php @@ -75,7 +75,7 @@ class CsvController extends Controller for ($i = 1; $i <= $count; $i++) { $headers[] = trans('firefly.csv_column') . ' #' . $i; } - if ($this->data->getHasHeaders()) { + if ($this->data->hasHeaders()) { $headers = $firstRow; } @@ -184,7 +184,6 @@ class CsvController extends Controller return redirect(route('csv.index')); } - // process given roles and mapping: $roles = $this->wizard->processSelectedRoles(Input::get('role')); $maps = $this->wizard->processSelectedMapping($roles, Input::get('map')); @@ -192,9 +191,7 @@ class CsvController extends Controller Session::put('csv-map', $maps); Session::put('csv-roles', $roles); - /* - * Go back when no roles defined: - */ + // Go back when no roles defined: if (count($roles) === 0) { Session::flash('warning', 'Please select some roles.'); @@ -256,7 +253,7 @@ class CsvController extends Controller // After these values are prepped, read the actual CSV file $reader = $this->data->getReader(); $map = $this->data->getMap(); - $hasHeaders = $this->data->getHasHeaders(); + $hasHeaders = $this->data->hasHeaders(); $values = $this->wizard->getMappableValues($reader, $map, $hasHeaders); $map = $this->data->getMap(); $mapped = $this->data->getMapped(); diff --git a/app/Repositories/Account/AccountRepository.php b/app/Repositories/Account/AccountRepository.php index 9bf61a3099..39b601a1c9 100644 --- a/app/Repositories/Account/AccountRepository.php +++ b/app/Repositories/Account/AccountRepository.php @@ -566,7 +566,6 @@ class AccountRepository implements AccountRepositoryInterface ); $journal->save(); - if ($data['openingBalance'] < 0) { $firstAccount = $opposing; $secondAccount = $account; @@ -578,26 +577,11 @@ class AccountRepository implements AccountRepositoryInterface $firstAmount = $data['openingBalance']; $secondAmount = $data['openingBalance'] * -1; } + $one = new Transaction(['account_id' => $firstAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $firstAmount]); + $one->save();// first transaction: from - // first transaction: from - $one = new Transaction( - [ - 'account_id' => $firstAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $firstAmount - ] - ); - $one->save(); - - // second transaction: to - $two = new Transaction( - [ - 'account_id' => $secondAccount->id, - 'transaction_journal_id' => $journal->id, - 'amount' => $secondAmount - ] - ); - $two->save(); + $two = new Transaction(['account_id' => $secondAccount->id, 'transaction_journal_id' => $journal->id, 'amount' => $secondAmount]); + $two->save(); // second transaction: to return $journal; @@ -606,6 +590,8 @@ class AccountRepository implements AccountRepositoryInterface /** * @param Account $account * @param array $data + * + * @SuppressWarnings(PHPMD.CyclomaticComplexity) */ protected function updateMetadata(Account $account, array $data) { diff --git a/app/Repositories/Journal/JournalRepository.php b/app/Repositories/Journal/JournalRepository.php index ae1882b4f9..169a746e40 100644 --- a/app/Repositories/Journal/JournalRepository.php +++ b/app/Repositories/Journal/JournalRepository.php @@ -115,14 +115,14 @@ class JournalRepository implements JournalRepositoryInterface } /** - * @param $id + * @param int $journalId * @param Carbon $date * * @return TransactionJournal */ - public function getWithDate($id, Carbon $date) + public function getWithDate($journalId, Carbon $date) { - return Auth::user()->transactionjournals()->where('id', $id)->where('date', $date->format('Y-m-d 00:00:00'))->first(); + return Auth::user()->transactionjournals()->where('id', $journalId)->where('date', $date->format('Y-m-d 00:00:00'))->first(); } /** diff --git a/app/Repositories/Journal/JournalRepositoryInterface.php b/app/Repositories/Journal/JournalRepositoryInterface.php index baaee122f2..fb7ccb6cc9 100644 --- a/app/Repositories/Journal/JournalRepositoryInterface.php +++ b/app/Repositories/Journal/JournalRepositoryInterface.php @@ -62,12 +62,12 @@ interface JournalRepositoryInterface public function getTransactionType($type); /** - * @param $id + * @param int $journalId * @param Carbon $date * * @return TransactionJournal */ - public function getWithDate($id, Carbon $date); + public function getWithDate($journalId, Carbon $date); /** * @param TransactionJournal $journal diff --git a/app/Validation/FireflyValidator.php b/app/Validation/FireflyValidator.php index 4d87ad39b8..3b11fbebb6 100644 --- a/app/Validation/FireflyValidator.php +++ b/app/Validation/FireflyValidator.php @@ -57,7 +57,8 @@ class FireflyValidator extends Validator /** * @param $attribute * @param $value - * @param $parameters + * + * @return bool */ public function validateIban($attribute, $value) { @@ -200,9 +201,10 @@ class FireflyValidator extends Validator /** * @param $value - * @param $parameters * * @return bool + * @internal param $parameters + * */ protected function validateByAccountId($value) { diff --git a/tests/_support/Helper/Acceptance.php b/tests/_support/Helper/Acceptance.php index dde208237b..ee5062d3e6 100644 --- a/tests/_support/Helper/Acceptance.php +++ b/tests/_support/Helper/Acceptance.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Acceptance + * + * @package Helper + */ class Acceptance extends \Codeception\Module { diff --git a/tests/_support/Helper/Functional.php b/tests/_support/Helper/Functional.php index 34fbe73652..1bd97acc12 100644 --- a/tests/_support/Helper/Functional.php +++ b/tests/_support/Helper/Functional.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Functional + * + * @package Helper + */ class Functional extends \Codeception\Module { diff --git a/tests/_support/Helper/Unit.php b/tests/_support/Helper/Unit.php index 4862e82dd7..6c520ad7dc 100644 --- a/tests/_support/Helper/Unit.php +++ b/tests/_support/Helper/Unit.php @@ -3,6 +3,11 @@ namespace Helper; // here you can define custom actions // all public methods declared in helper class will be available in $I +/** + * Class Unit + * + * @package Helper + */ class Unit extends \Codeception\Module { diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 2e30fdcee4..c11f2f30d5 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -8,6 +8,11 @@ namespace _generated; use Codeception\Module\PhpBrowser; use Helper\Acceptance; +/** + * Class AcceptanceTesterActions + * + * @package _generated + */ trait AcceptanceTesterActions { /** diff --git a/tests/_support/_generated/FunctionalTesterActions.php b/tests/_support/_generated/FunctionalTesterActions.php index 0d6c61fe91..293b5d56ef 100644 --- a/tests/_support/_generated/FunctionalTesterActions.php +++ b/tests/_support/_generated/FunctionalTesterActions.php @@ -7,6 +7,11 @@ namespace _generated; use Helper\Functional; +/** + * Class FunctionalTesterActions + * + * @package _generated + */ trait FunctionalTesterActions { /** diff --git a/tests/_support/_generated/UnitTesterActions.php b/tests/_support/_generated/UnitTesterActions.php index 32aa10351e..886e82ea5b 100644 --- a/tests/_support/_generated/UnitTesterActions.php +++ b/tests/_support/_generated/UnitTesterActions.php @@ -9,6 +9,11 @@ use Codeception\Module\Laravel5; use Codeception\Module\Asserts; use Helper\Unit; +/** + * Class UnitTesterActions + * + * @package _generated + */ trait UnitTesterActions { /**