Code cleanup that (hopefully) matches style CI

This commit is contained in:
James Cole
2020-03-17 15:02:57 +01:00
parent 2b6c3fd743
commit 24129ab69c
21 changed files with 266 additions and 257 deletions

View File

@@ -62,7 +62,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->findNull((int)$accountId);
$account = $repository->findNull((int) $accountId);
if (null !== $account) {
$collection->push($account);
}
@@ -85,7 +85,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $budgetId) {
$budget = $repository->findNull((int)$budgetId);
$budget = $repository->findNull((int) $budgetId);
if (null !== $budget) {
$collection->push($budget);
}
@@ -108,7 +108,7 @@ class ReportFormRequest extends Request
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $categoryId) {
$category = $repository->findNull((int)$categoryId);
$category = $repository->findNull((int) $categoryId);
if (null !== $category) {
$collection->push($category);
}
@@ -118,18 +118,41 @@ class ReportFormRequest extends Request
return $collection;
}
/**
* Validate list of accounts which exist twice in system.
*
* @return Collection
*/
public function getDoubleList(): Collection
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$set = $this->get('double');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->findNull((int) $accountId);
if (null !== $account) {
$collection->push($account);
}
}
}
return $collection;
}
/**
* Validate end date.
*
* @throws FireflyException
* @return Carbon
*
* @throws FireflyException
*/
public function getEndDate(): Carbon
{
$date = new Carbon;
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
$parts = explode(' - ', (string) $range);
if (2 === count($parts)) {
try {
$date = new Carbon($parts[1]);
@@ -146,41 +169,18 @@ class ReportFormRequest extends Request
return $date;
}
/**
* Validate list of accounts which exist twice in system.
*
* @return Collection
*/
public function getDoubleList(): Collection
{
/** @var AccountRepositoryInterface $repository */
$repository = app(AccountRepositoryInterface::class);
$set = $this->get('double');
$collection = new Collection;
if (is_array($set)) {
foreach ($set as $accountId) {
$account = $repository->findNull((int)$accountId);
if (null !== $account) {
$collection->push($account);
}
}
}
return $collection;
}
/**
* Validate start date.
*
* @throws FireflyException
* @return Carbon
*
* @throws FireflyException
*/
public function getStartDate(): Carbon
{
$date = new Carbon;
$range = $this->get('daterange');
$parts = explode(' - ', (string)$range);
$parts = explode(' - ', (string) $range);
if (2 === count($parts)) {
try {
$date = new Carbon($parts[0]);
@@ -216,7 +216,7 @@ class ReportFormRequest extends Request
$collection->push($tag);
continue;
}
$tag = $repository->findNull((int)$tagTag);
$tag = $repository->findNull((int) $tagTag);
if (null !== $tag) {
$collection->push($tag);
continue;