Skip to content

Firefly III: a personal finances manager

Some cleaning up.

James Coleb70498c337b5
diff --git a/_development/phpmd/phpmd.xml b/_development/phpmd/phpmd.xml
index b8b5db0e92..1e24a5344d 100644
--- a/_development/phpmd/phpmd.xml
+++ b/_development/phpmd/phpmd.xml
@@ -6,50 +6,50 @@ command line:
phpmd app html ./_development/phpmd/phpmd.xml > ./public/result.html
-->
-<ruleset name="pcsg-generated-ruleset"
- xmlns="http://pmd.sf.net/ruleset/1.0.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
- xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
- <description>Bla bla</description>
-
- <!-- Import the entire controversial code rule set, except one -->
- <rule ref="rulesets/controversial.xml">
- <exclude name="CamelCasePropertyName" />
- </rule>
-
- <!-- clean code -->
- <!-- <rule ref="rulesets/cleancode.xml" /> -->
- <rule ref="rulesets/codesize.xml" />
- <rule ref="rulesets/design.xml" />
- <rule ref="rulesets/naming.xml" />
- <rule ref="rulesets/unusedcode.xml" />
-
- <!-- clean code static calling rule can be a little more lax: -->
- <rule ref="rulesets/cleancode.xml">
- <exclude name="StaticAccess" />
- </rule>
-
-
- <!-- report level 5 for cyclomatic complexity -->
- <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
- <properties>
- <property name="reportLevel" value="5"/>
- </properties>
- </rule>
- <rule ref="rulesets/codesize.xml/NPathComplexity">
- <properties>
- <property name="minimum" value="128"/>
- </properties>
- </rule>
- <rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
- <properties>
- <property name="minimum" value="40"/>
- </properties>
- </rule>
- <rule ref="rulesets/codesize.xml/ExcessiveParameterList">
- <properties>
- <property name="minimum" value="5"/>
- </properties>
- </rule>
+<ruleset name="pcsg-generated-ruleset"
+ xmlns="http://pmd.sf.net/ruleset/1.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://pmd.sf.net/ruleset/1.0.0 http://pmd.sf.net/ruleset_xml_schema.xsd"
+ xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd">
+ <description>Bla bla</description>
+
+ <!-- Import the entire controversial code rule set, except one -->
+ <rule ref="rulesets/controversial.xml">
+ <exclude name="CamelCasePropertyName"/>
+ </rule>
+
+ <!-- clean code -->
+ <!-- <rule ref="rulesets/cleancode.xml" /> -->
+ <rule ref="rulesets/codesize.xml"/>
+ <rule ref="rulesets/design.xml"/>
+ <rule ref="rulesets/naming.xml"/>
+ <rule ref="rulesets/unusedcode.xml"/>
+
+ <!-- clean code static calling rule can be a little more lax: -->
+ <rule ref="rulesets/cleancode.xml">
+ <exclude name="StaticAccess"/>
+ </rule>
+
+
+ <!-- report level 5 for cyclomatic complexity -->
+ <rule ref="rulesets/codesize.xml/CyclomaticComplexity">
+ <properties>
+ <property name="reportLevel" value="5"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/codesize.xml/NPathComplexity">
+ <properties>
+ <property name="minimum" value="128"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/codesize.xml/ExcessiveMethodLength">
+ <properties>
+ <property name="minimum" value="40"/>
+ </properties>
+ </rule>
+ <rule ref="rulesets/codesize.xml/ExcessiveParameterList">
+ <properties>
+ <property name="minimum" value="5"/>
+ </properties>
+ </rule>
</ruleset>
\ No newline at end of file
diff --git a/app/Helpers/Csv/Converter/OpposingAccountIban.php b/app/Helpers/Csv/Converter/OpposingAccountIban.php
index cf7c22ed34..e75c3b5abd 100644
--- a/app/Helpers/Csv/Converter/OpposingAccountIban.php
+++ b/app/Helpers/Csv/Converter/OpposingAccountIban.php
@@ -28,7 +28,17 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
return $account;
}
-
+
+ return $this->findAccount($repository);
+ }
+
+ /**
+ * @param AccountRepositoryInterface $repository
+ *
+ * @return Account|string
+ */
+ private function findAccount(AccountRepositoryInterface $repository)
+ {
if (strlen($this->value) > 0) {
$set = $repository->getAccounts([]);
@@ -42,7 +52,6 @@ class OpposingAccountIban extends BasicConverter implements ConverterInterface
}
return $this->value;
-
}
}
diff --git a/app/Helpers/Csv/PostProcessing/OpposingAccount.php b/app/Helpers/Csv/PostProcessing/OpposingAccount.php
index dece4bea05..c0add69540 100644
--- a/app/Helpers/Csv/PostProcessing/OpposingAccount.php
+++ b/app/Helpers/Csv/PostProcessing/OpposingAccount.php
@@ -54,6 +54,26 @@ class OpposingAccount implements PostProcessorInterface
$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
*/
@@ -78,41 +98,22 @@ class OpposingAccount implements PostProcessorInterface
/**
* @return array|null
*/
- protected function checkIbanString()
+ protected function checkNameString()
{
- $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();
+ if ($this->data['opposing-account-name'] instanceof Account) { // third: try to find account based on name, if any.
+ Log::debug('OpposingAccountPostProcession: opposing-account-name is an Account.');
+ $this->data['opposing-account-object'] = $this->data['opposing-account-name'];
return $this->data;
}
+ if (is_string($this->data['opposing-account-name'])) {
- 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.');
+ $this->data['opposing-account-object'] = $this->parseNameString();
- return $entry;
- }
+ return $this->data;
}
- $account = $this->createAccount();
-
- return $account;
+ return null;
}
/**
@@ -150,34 +151,33 @@ class OpposingAccount implements PostProcessorInterface
// create expense account:
return AccountType::where('type', 'Expense account')->first();
- } else {
- // create revenue account:
+ }
- return AccountType::where('type', 'Revenue account')->first();
+ // create revenue account:
+
+ 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.
- Log::debug('OpposingAccountPostProcession: opposing-account-name is an Account.');
- $this->data['opposing-account-object'] = $this->data['opposing-account-name'];
+ // 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 $this->data;
+ return $entry;
+ }
}
- if (is_string($this->data['opposing-account-name'])) {
-
- $this->data['opposing-account-object'] = $this->parseNameString();
+ $account = $this->createAccount();
- return $this->data;
- }
- return null;
+ return $account;
}
/**