Code cleanup and documentation improvements.

This commit is contained in:
James Cole
2018-07-06 07:15:42 +02:00
parent bdc6678341
commit a76241c7ba
49 changed files with 342 additions and 82 deletions

View File

@@ -1,5 +1,4 @@
<?php
/**
* AccountController.php
* Copyright (c) 2018 thegrumpydictator@gmail.com
@@ -41,14 +40,15 @@ use League\Fractal\Resource\Item;
use League\Fractal\Serializer\JsonApiSerializer;
/**
* Class AccountController
* Class AccountController.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class AccountController extends Controller
{
/** @var CurrencyRepositoryInterface */
/** @var CurrencyRepositoryInterface The currency repository */
private $currencyRepository;
/** @var AccountRepositoryInterface */
/** @var AccountRepositoryInterface The account repository */
private $repository;
/**
@@ -126,6 +126,8 @@ class AccountController extends Controller
}
/**
* Show single instance.
*
* @param Request $request
* @param Account $account
*
@@ -147,6 +149,8 @@ class AccountController extends Controller
}
/**
* Store a new instance.
*
* @param AccountRequest $request
*
* @return \Illuminate\Http\JsonResponse
@@ -198,13 +202,15 @@ class AccountController extends Controller
}
/**
* All the available types.
*
* @param string $type
*
* @return array
*/
private function mapTypes(string $type): array
{
$types = [
$types = [
'all' => [AccountType::DEFAULT, AccountType::CASH, AccountType::ASSET, AccountType::EXPENSE, AccountType::REVENUE,
AccountType::INITIAL_BALANCE, AccountType::BENEFICIARY, AccountType::IMPORT, AccountType::RECONCILIATION,
AccountType::LOAN,],
@@ -226,10 +232,11 @@ class AccountController extends Controller
AccountType::RECONCILIATION => [AccountType::RECONCILIATION],
AccountType::LOAN => [AccountType::LOAN],
];
$return = $types['all'];
if (isset($types[$type])) {
return $types[$type];
$return = $types[$type];
}
return $types['all']; // @codeCoverageIgnore
return $return; // @codeCoverageIgnore
}
}