Code cleanup

This commit is contained in:
James Cole
2021-03-21 09:15:40 +01:00
parent da1751940e
commit 206845575c
317 changed files with 7418 additions and 7362 deletions

View File

@@ -86,21 +86,21 @@ class OperatorQuerySearch implements SearchInterface
private BillRepositoryInterface $billRepository;
private BudgetRepositoryInterface $budgetRepository;
private CategoryRepositoryInterface $categoryRepository;
private TagRepositoryInterface $tagRepository;
private CurrencyRepositoryInterface $currencyRepository;
private TransactionTypeRepositoryInterface $typeRepository;
private User $user;
private ParsedQuery $query;
private int $page;
private int $limit;
private array $words;
private array $validOperators;
private GroupCollectorInterface $collector;
private float $startTime;
private Collection $modifiers; // obsolete
private CurrencyRepositoryInterface $currencyRepository;
private Carbon $date;
private int $limit;
private Collection $modifiers;
private Collection $operators;
private string $originalQuery;
private Carbon $date;
private int $page;
private ParsedQuery $query;
private float $startTime;
private TagRepositoryInterface $tagRepository;
private TransactionTypeRepositoryInterface $typeRepository; // obsolete
private User $user;
private array $validOperators;
private array $words;
/**
* OperatorQuerySearch constructor.
@@ -146,14 +146,6 @@ class OperatorQuerySearch implements SearchInterface
return $this->operators;
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$this->date = $date;
}
/**
* @inheritDoc
* @codeCoverageIgnore
@@ -163,24 +155,6 @@ class OperatorQuerySearch implements SearchInterface
return implode(' ', $this->words);
}
/**
* @return array
*/
public function getWords(): array
{
return $this->words;
}
/**
* @inheritDoc
* @codeCoverageIgnore
*/
public function setPage(int $page): void
{
$this->page = $page;
$this->collector->setPage($this->page);
}
/**
* @inheritDoc
* @codeCoverageIgnore
@@ -231,6 +205,33 @@ class OperatorQuerySearch implements SearchInterface
return $this->collector->getPaginatedGroups();
}
/**
* @param Carbon $date
*/
public function setDate(Carbon $date): void
{
$this->date = $date;
}
/**
* @param int $limit
*/
public function setLimit(int $limit): void
{
$this->limit = $limit;
$this->collector->setLimit($this->limit);
}
/**
* @inheritDoc
* @codeCoverageIgnore
*/
public function setPage(int $page): void
{
$this->page = $page;
$this->collector->setPage($this->page);
}
/**
* @inheritDoc
* @codeCoverageIgnore
@@ -644,6 +645,28 @@ class OperatorQuerySearch implements SearchInterface
return true;
}
/**
* @param string $operator
*
* @return string
* @throws FireflyException
*/
public static function getRootOperator(string $operator): string
{
$config = config(sprintf('firefly.search.operators.%s', $operator));
if (null === $config) {
throw new FireflyException(sprintf('No configuration for search operator "%s"', $operator));
}
if (true === $config['alias']) {
Log::debug(sprintf('"%s" is an alias for "%s", so return that instead.', $operator, $config['alias_for']));
return $config['alias_for'];
}
Log::debug(sprintf('"%s" is not an alias.', $operator));
return $operator;
}
/**
* searchDirection: 1 = source (default), 2 = destination
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
@@ -709,7 +732,6 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->$collectorMethod($filtered);
}
/**
* searchDirection: 1 = source (default), 2 = destination
* stringPosition: 1 = start (default), 2 = end, 3 = contains, 4 = is
@@ -787,6 +809,14 @@ class OperatorQuerySearch implements SearchInterface
$this->collector->$collectorMethod($filtered);
}
/**
* @return Account
*/
private function getCashAccount(): Account
{
return $this->accountRepository->getCashAccount();
}
/**
* @param string $value
*
@@ -809,28 +839,6 @@ class OperatorQuerySearch implements SearchInterface
return $result;
}
/**
* @param string $operator
*
* @return string
* @throws FireflyException
*/
public static function getRootOperator(string $operator): string
{
$config = config(sprintf('firefly.search.operators.%s', $operator));
if (null === $config) {
throw new FireflyException(sprintf('No configuration for search operator "%s"', $operator));
}
if (true === $config['alias']) {
Log::debug(sprintf('"%s" is an alias for "%s", so return that instead.', $operator, $config['alias_for']));
return $config['alias_for'];
}
Log::debug(sprintf('"%s" is not an alias.', $operator));
return $operator;
}
/**
* @param string $value
*
@@ -852,19 +860,10 @@ class OperatorQuerySearch implements SearchInterface
}
/**
* @param int $limit
* @return array
*/
public function setLimit(int $limit): void
public function getWords(): array
{
$this->limit = $limit;
$this->collector->setLimit($this->limit);
}
/**
* @return Account
*/
private function getCashAccount(): Account
{
return $this->accountRepository->getCashAccount();
return $this->words;
}
}