mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-12 15:35:15 +00:00
Various code cleanup.
This commit is contained in:
@@ -47,14 +47,14 @@ class AccountList implements BinderInterface
|
||||
if (auth()->check()) {
|
||||
|
||||
$collection = new Collection;
|
||||
if ($value === 'allAssetAccounts') {
|
||||
if ('allAssetAccounts' === $value) {
|
||||
/** @var \Illuminate\Support\Collection $collection */
|
||||
$collection = auth()->user()->accounts()
|
||||
->leftJoin('account_types', 'account_types.id', '=', 'accounts.account_type_id')
|
||||
->where('account_types.type', AccountType::ASSET)
|
||||
->get(['accounts.*']);
|
||||
}
|
||||
if ($value !== 'allAssetAccounts') {
|
||||
if ('allAssetAccounts' !== $value) {
|
||||
|
||||
$list = [];
|
||||
$incoming = explode(',', $value);
|
||||
@@ -62,7 +62,7 @@ class AccountList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Account list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ class BudgetList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ class BudgetList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty budget if applicable.
|
||||
if (\in_array(0, $list)) {
|
||||
if (\in_array(0, $list, true)) {
|
||||
$collection->push(new Budget);
|
||||
}
|
||||
|
||||
|
@@ -48,7 +48,7 @@ class CategoryList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ class CategoryList implements BinderInterface
|
||||
->get();
|
||||
|
||||
// add empty category if applicable.
|
||||
if (\in_array(0, $list)) {
|
||||
if (\in_array(0, $list, true)) {
|
||||
$collection->push(new Category);
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ class Date implements BinderInterface
|
||||
try {
|
||||
$date = new Carbon($value);
|
||||
} catch (Exception $e) {
|
||||
Log::error('Could not parse date "' . $value . '" for user #' . auth()->user()->id);
|
||||
Log::error(sprintf('Could not parse date "%s" for user #%d: %s', $value, auth()->user()->id, $e->getMessage()));
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
|
@@ -27,30 +27,14 @@ use FireflyIII\Import\Prerequisites\PrerequisitesInterface;
|
||||
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
||||
use FireflyIII\User;
|
||||
use Illuminate\Routing\Route;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
use Log;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Class ImportProvider.
|
||||
*/
|
||||
class ImportProvider implements BinderInterface
|
||||
{
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$providers = array_keys(self::getProviders());
|
||||
if (\in_array($value, $providers, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
@@ -99,4 +83,20 @@ class ImportProvider implements BinderInterface
|
||||
|
||||
return $providers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @param Route $route
|
||||
*
|
||||
* @return Carbon
|
||||
* @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
|
||||
*/
|
||||
public static function routeBinder(string $value, Route $route): string
|
||||
{
|
||||
$providers = array_keys(self::getProviders());
|
||||
if (\in_array($value, $providers, true)) {
|
||||
return $value;
|
||||
}
|
||||
throw new NotFoundHttpException;
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class JournalList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ class SimpleJournalList implements BinderInterface
|
||||
$list[] = (int)$entry;
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
|
@@ -50,7 +50,7 @@ class TagList implements BinderInterface
|
||||
$list[] = strtolower(trim($entry));
|
||||
}
|
||||
$list = array_unique($list);
|
||||
if (\count($list) === 0) {
|
||||
if (0 === \count($list)) {
|
||||
Log::error('Tag list is empty.');
|
||||
throw new NotFoundHttpException; // @codeCoverageIgnore
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class TagList implements BinderInterface
|
||||
|
||||
$collection = $allTags->filter(
|
||||
function (Tag $tag) use ($list) {
|
||||
return \in_array(strtolower($tag->tag), $list);
|
||||
return \in_array(strtolower($tag->tag), $list, true);
|
||||
}
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user