Refactor findNull to find

This commit is contained in:
James Cole
2021-06-30 06:17:38 +02:00
parent b7ae5eda35
commit 70da5917c9
68 changed files with 120 additions and 273 deletions

View File

@@ -71,14 +71,9 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
*
* @return PiggyBank|null
*/
public function findNull(int $piggyBankId): ?PiggyBank
public function find(int $piggyBankId): ?PiggyBank
{
$piggyBank = $this->user->piggyBanks()->where('piggy_banks.id', $piggyBankId)->first(['piggy_banks.*']);
if (null !== $piggyBank) {
return $piggyBank;
}
return null;
$piggyBank = $this->user->piggyBanks()->find($piggyBankId);
}
/**
@@ -92,7 +87,7 @@ class PiggyBankRepository implements PiggyBankRepositoryInterface
Log::debug('Searching for piggy information.');
if (null !== $piggyBankId) {
$searchResult = $this->findNull((int)$piggyBankId);
$searchResult = $this->find((int)$piggyBankId);
if (null !== $searchResult) {
Log::debug(sprintf('Found piggy based on #%d, will return it.', $piggyBankId));

View File

@@ -115,7 +115,7 @@ interface PiggyBankRepositoryInterface
*
* @return PiggyBank|null
*/
public function findNull(int $piggyBankId): ?PiggyBank;
public function find(int $piggyBankId): ?PiggyBank;
/**
* @param int|null $piggyBankId