Code cleanup

This commit is contained in:
James Cole
2018-04-02 15:10:40 +02:00
parent fa7ab45a40
commit a3c34e6b3c
151 changed files with 802 additions and 990 deletions

View File

@@ -49,7 +49,7 @@ class ImportAccount
/** @var int */
private $defaultAccountId = 0;
/** @var string */
private $expectedType = '';
private $expectedType;
/**
* This value is used to indicate the other account ID (the opposing transaction's account),
* if it is know. If so, this particular import account may never return an Account with this ID.
@@ -299,19 +299,19 @@ class ImportAccount
/** @var AccountType $accountType */
$accountType = $this->repository->getAccountType($this->expectedType);
$result = $this->findById($accountType);
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
$result = $this->findByIBAN($accountType);
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
$result = $this->findByName($accountType);
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
@@ -365,7 +365,7 @@ class ImportAccount
Log::debug('Finding a mapped account based on', $array);
$search = intval($array['mapped'] ?? 0);
$search = (int)($array['mapped'] ?? 0.0);
$account = $this->repository->findNull($search);
if (null === $account) {
@@ -401,10 +401,10 @@ class ImportAccount
*/
private function store(): bool
{
if (is_null($this->user)) {
if (null === $this->user) {
throw new FireflyException('ImportAccount cannot continue without user.');
}
if ((is_null($this->defaultAccountId) || 0 === intval($this->defaultAccountId)) && AccountType::ASSET === $this->expectedType) {
if ((null === $this->defaultAccountId || 0 === (int)$this->defaultAccountId) && AccountType::ASSET === $this->expectedType) {
throw new FireflyException('ImportAccount cannot continue without a default account to fall back on.');
}
// 1: find mapped object:

View File

@@ -108,7 +108,7 @@ class ImportBill
if (3 === count($this->id)) {
Log::debug(sprintf('Finding bill with ID #%d', $this->id['value']));
/** @var Bill $bill */
$bill = $this->repository->find(intval($this->id['value']));
$bill = $this->repository->find((int)$this->id['value']);
if (null !== $bill) {
Log::debug(sprintf('Found unmapped bill by ID (#%d): %s', $bill->id, $bill->name));
@@ -157,11 +157,11 @@ class ImportBill
{
Log::debug('In findExistingObject() for Bill');
$result = $this->findById();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
$result = $this->findByName();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
@@ -215,7 +215,7 @@ class ImportBill
Log::debug('Finding a mapped bill based on', $array);
$search = intval($array['mapped']);
$search = (int)$array['mapped'];
$bill = $this->repository->find($search);
if (null === $bill) {

View File

@@ -97,7 +97,7 @@ class ImportBudget
if (3 === count($this->id)) {
Log::debug(sprintf('Finding budget with ID #%d', $this->id['value']));
/** @var Budget $budget */
$budget = $this->repository->findNull(intval($this->id['value']));
$budget = $this->repository->findNull((int)$this->id['value']);
if (null !== $budget) {
Log::debug(sprintf('Found unmapped budget by ID (#%d): %s', $budget->id, $budget->name));
@@ -146,11 +146,11 @@ class ImportBudget
{
Log::debug('In findExistingObject() for Budget');
$result = $this->findById();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
$result = $this->findByName();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
@@ -204,7 +204,7 @@ class ImportBudget
Log::debug('Finding a mapped budget based on', $array);
$search = intval($array['mapped']);
$search = (int)$array['mapped'];
$budget = $this->repository->find($search);
if (null === $budget->id) {

View File

@@ -99,7 +99,7 @@ class ImportCategory
if (3 === count($this->id)) {
Log::debug(sprintf('Finding category with ID #%d', $this->id['value']));
/** @var Category $category */
$category = $this->repository->findNull(intval($this->id['value']));
$category = $this->repository->findNull((int)$this->id['value']);
if (null !== $category) {
Log::debug(sprintf('Found unmapped category by ID (#%d): %s', $category->id, $category->name));
@@ -150,12 +150,12 @@ class ImportCategory
{
Log::debug('In findExistingObject() for Category');
$result = $this->findById();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
$result = $this->findByName();
if (!is_null($result)) {
if (null !== $result) {
return $result;
}
@@ -209,7 +209,7 @@ class ImportCategory
Log::debug('Finding a mapped category based on', $array);
$search = intval($array['mapped']);
$search = (int)$array['mapped'];
$category = $this->repository->findNull($search);
if (null === $category) {

View File

@@ -114,7 +114,7 @@ class ImportCurrency
*/
public function setId(array $id)
{
$id['value'] = intval($id['value']);
$id['value'] = (int)$id['value'];
$this->id = $id;
}
@@ -215,7 +215,7 @@ class ImportCurrency
Log::debug('Finding a mapped object based on', $array);
$search = intval($array['mapped']);
$search = (int)$array['mapped'];
$currency = $this->repository->findNull($search);
if (null === $currency) {

View File

@@ -71,7 +71,7 @@ class ImportJournal
/** @var array */
private $amountDebit;
/** @var string */
private $convertedAmount = null;
private $convertedAmount;
/** @var string */
private $date = '';
/** @var string */
@@ -225,7 +225,7 @@ class ImportJournal
public function getMetaString(string $field): ?string
{
if (isset($this->metaFields[$field]) && strlen($this->metaFields[$field]) > 0) {
return strval($this->metaFields[$field]);
return (string)$this->metaFields[$field];
}
return null;
@@ -277,7 +277,7 @@ class ImportJournal
case 'sepa-country':
case 'sepa-ep':
case 'sepa-ci':
$value = trim(strval($array['value']));
$value = trim((string)$array['value']);
if (strlen($value) > 0) {
$this->metaFields[$array['role']] = $value;
}
@@ -448,17 +448,17 @@ class ImportJournal
{
$info = [];
$converterClass = '';
if (!is_null($this->amount)) {
if (null !== $this->amount) {
Log::debug('Amount value is not NULL, assume this is the correct value.');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amount['role'])));
$info = $this->amount;
}
if (!is_null($this->amountDebit)) {
if (null !== $this->amountDebit) {
Log::debug('Amount DEBIT value is not NULL, assume this is the correct value (overrules Amount).');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountDebit['role'])));
$info = $this->amountDebit;
}
if (!is_null($this->amountCredit)) {
if (null !== $this->amountCredit) {
Log::debug('Amount CREDIT value is not NULL, assume this is the correct value (overrules Amount and AmountDebit).');
$converterClass = sprintf('FireflyIII\Import\Converter\%s', config(sprintf('csv.import_roles.%s.converter', $this->amountCredit['role'])));
$info = $this->amountCredit;