mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2024-12-28 09:51:21 -06:00
Some cleaning up.
This commit is contained in:
parent
f34aa77d1d
commit
b70498c337
@ -15,19 +15,19 @@ phpmd app html ./_development/phpmd/phpmd.xml > ./public/result.html
|
|||||||
|
|
||||||
<!-- Import the entire controversial code rule set, except one -->
|
<!-- Import the entire controversial code rule set, except one -->
|
||||||
<rule ref="rulesets/controversial.xml">
|
<rule ref="rulesets/controversial.xml">
|
||||||
<exclude name="CamelCasePropertyName" />
|
<exclude name="CamelCasePropertyName"/>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- clean code -->
|
<!-- clean code -->
|
||||||
<!-- <rule ref="rulesets/cleancode.xml" /> -->
|
<!-- <rule ref="rulesets/cleancode.xml" /> -->
|
||||||
<rule ref="rulesets/codesize.xml" />
|
<rule ref="rulesets/codesize.xml"/>
|
||||||
<rule ref="rulesets/design.xml" />
|
<rule ref="rulesets/design.xml"/>
|
||||||
<rule ref="rulesets/naming.xml" />
|
<rule ref="rulesets/naming.xml"/>
|
||||||
<rule ref="rulesets/unusedcode.xml" />
|
<rule ref="rulesets/unusedcode.xml"/>
|
||||||
|
|
||||||
<!-- clean code static calling rule can be a little more lax: -->
|
<!-- clean code static calling rule can be a little more lax: -->
|
||||||
<rule ref="rulesets/cleancode.xml">
|
<rule ref="rulesets/cleancode.xml">
|
||||||
<exclude name="StaticAccess" />
|
<exclude name="StaticAccess"/>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
|
||||||
|
@ -29,6 +29,16 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
|||||||
return $account;
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this->findAccount($repository);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param AccountRepositoryInterface $repository
|
||||||
|
*
|
||||||
|
* @return Account|string
|
||||||
|
*/
|
||||||
|
private function findAccount(AccountRepositoryInterface $repository)
|
||||||
|
{
|
||||||
if (strlen($this->value) > 0) {
|
if (strlen($this->value) > 0) {
|
||||||
|
|
||||||
$set = $repository->getAccounts([]);
|
$set = $repository->getAccounts([]);
|
||||||
@ -42,7 +52,6 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this->value;
|
return $this->value;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,26 @@ class OpposingAccount implements PostProcessorInterface
|
|||||||
$this->data = $data;
|
$this->data = $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
protected function checkIbanString()
|
||||||
|
{
|
||||||
|
$rules = ['iban' => 'iban'];
|
||||||
|
$iban = $this->data['opposing-account-iban'];
|
||||||
|
$check = ['iban' => $iban];
|
||||||
|
$validator = Validator::make($check, $rules);
|
||||||
|
if (is_string($iban) && strlen($iban) > 0 && !$validator->fails()) {
|
||||||
|
|
||||||
|
Log::debug('OpposingAccountPostProcession: opposing-account-iban is a string (******).');
|
||||||
|
$this->data['opposing-account-object'] = $this->parseIbanString();
|
||||||
|
|
||||||
|
return $this->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
@ -78,16 +98,17 @@ class OpposingAccount implements PostProcessorInterface
|
|||||||
/**
|
/**
|
||||||
* @return array|null
|
* @return array|null
|
||||||
*/
|
*/
|
||||||
protected function checkIbanString()
|
protected function checkNameString()
|
||||||
{
|
{
|
||||||
$rules = ['iban' => 'iban'];
|
if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any.
|
||||||
$iban = $this->data['opposing-account-iban'];
|
Log::debug('OpposingAccountPostProcession: opposing-account-name is an Account.');
|
||||||
$check = ['iban' => $iban];
|
$this->data['opposing-account-object'] = $this->data['opposing-account-name'];
|
||||||
$validator = Validator::make($check, $rules);
|
|
||||||
if (is_string($iban) && strlen($iban) > 0 && !$validator->fails()) {
|
|
||||||
|
|
||||||
Log::debug('OpposingAccountPostProcession: opposing-account-iban is a string (******).');
|
return $this->data;
|
||||||
$this->data['opposing-account-object'] = $this->parseIbanString();
|
}
|
||||||
|
if (is_string($this->data['opposing-account-name'])) {
|
||||||
|
|
||||||
|
$this->data['opposing-account-object'] = $this->parseNameString();
|
||||||
|
|
||||||
return $this->data;
|
return $this->data;
|
||||||
}
|
}
|
||||||
@ -95,26 +116,6 @@ class OpposingAccount implements PostProcessorInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return Account|null
|
|
||||||
*/
|
|
||||||
protected function parseIbanString()
|
|
||||||
{
|
|
||||||
// create by name and/or iban.
|
|
||||||
$accounts = Auth::user()->accounts()->get();
|
|
||||||
foreach ($accounts as $entry) {
|
|
||||||
if ($entry->iban == $this->data['opposing-account-iban']) {
|
|
||||||
Log::debug('OpposingAccountPostProcession: opposing-account-iban matches an Account.');
|
|
||||||
|
|
||||||
return $entry;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$account = $this->createAccount();
|
|
||||||
|
|
||||||
|
|
||||||
return $account;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Account|null
|
* @return Account|null
|
||||||
*/
|
*/
|
||||||
@ -150,34 +151,33 @@ class OpposingAccount implements PostProcessorInterface
|
|||||||
// create expense account:
|
// create expense account:
|
||||||
|
|
||||||
return AccountType::where('type', 'Expense account')->first();
|
return AccountType::where('type', 'Expense account')->first();
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// create revenue account:
|
// create revenue account:
|
||||||
|
|
||||||
return AccountType::where('type', 'Revenue account')->first();
|
return AccountType::where('type', 'Revenue account')->first();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return array|null
|
* @return Account|null
|
||||||
*/
|
*/
|
||||||
protected function checkNameString()
|
protected function parseIbanString()
|
||||||
{
|
{
|
||||||
if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any.
|
// create by name and/or iban.
|
||||||
Log::debug('OpposingAccountPostProcession: opposing-account-name is an Account.');
|
$accounts = Auth::user()->accounts()->get();
|
||||||
$this->data['opposing-account-object'] = $this->data['opposing-account-name'];
|
foreach ($accounts as $entry) {
|
||||||
|
if ($entry->iban == $this->data['opposing-account-iban']) {
|
||||||
|
Log::debug('OpposingAccountPostProcession: opposing-account-iban matches an Account.');
|
||||||
|
|
||||||
return $this->data;
|
return $entry;
|
||||||
}
|
}
|
||||||
if (is_string($this->data['opposing-account-name'])) {
|
|
||||||
|
|
||||||
$this->data['opposing-account-object'] = $this->parseNameString();
|
|
||||||
|
|
||||||
return $this->data;
|
|
||||||
}
|
}
|
||||||
|
$account = $this->createAccount();
|
||||||
|
|
||||||
return null;
|
|
||||||
|
return $account;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user