Code clean up.

This commit is contained in:
James Cole
2017-11-15 12:25:49 +01:00
parent 57dcdfa0c4
commit ffca858b8d
476 changed files with 2055 additions and 4181 deletions

View File

@@ -18,24 +18,21 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
/**
* Class AbnAmroDescription
* Class AbnAmroDescription.
*
* Parses the description from txt files for ABN AMRO bank accounts.
*
* Based on the logic as described in the following Gist:
* https://gist.github.com/vDorst/68d555a6a90f62fec004
*
* @package FireflyIII\Import\Specifics
*/
class AbnAmroDescription implements SpecificInterface
{
/** @var array */
/** @var array */
public $row;
/**
@@ -70,7 +67,6 @@ class AbnAmroDescription implements SpecificInterface
// Try to parse the description in known formats.
$parsed = $this->parseSepaDescription() || $this->parseTRTPDescription() || $this->parseGEABEADescription() || $this->parseABNAMRODescription();
// If the description could not be parsed, specify an unknown opposing
// account, as an opposing account is required
if (!$parsed) {
@@ -81,7 +77,7 @@ class AbnAmroDescription implements SpecificInterface
}
/**
* Parses the current description with costs from ABN AMRO itself
* Parses the current description with costs from ABN AMRO itself.
*
* @return bool true if the description is GEA/BEA-format, false otherwise
*/
@@ -99,7 +95,7 @@ class AbnAmroDescription implements SpecificInterface
}
/**
* Parses the current description in GEA/BEA format
* Parses the current description in GEA/BEA format.
*
* @return bool true if the description is GEA/BEAformat, false otherwise
*/
@@ -107,12 +103,11 @@ class AbnAmroDescription implements SpecificInterface
{
// See if the current description is formatted in GEA/BEA format
if (preg_match('/([BG]EA) +(NR:[a-zA-Z:0-9]+) +([0-9.\/]+) +([^,]*)/', $this->row[7], $matches)) {
// description and opposing account will be the same.
$this->row[8] = $matches[4]; // 'opposing-account-name'
$this->row[7] = $matches[4]; // 'description'
if ($matches[1] === 'GEA') {
if ('GEA' === $matches[1]) {
$this->row[7] = 'GEA ' . $matches[4]; // 'description'
}
@@ -123,7 +118,8 @@ class AbnAmroDescription implements SpecificInterface
}
/**
* Parses the current description in SEPA format
* Parses the current description in SEPA format.
*
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*
* @return bool true if the description is SEPA format, false otherwise
@@ -167,7 +163,7 @@ class AbnAmroDescription implements SpecificInterface
// Set a new description for the current transaction. If none was given
// set the description to type, name and reference
$this->row[7] = $newDescription;
if (strlen($newDescription) === 0) {
if (0 === strlen($newDescription)) {
$this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference);
}
@@ -178,7 +174,7 @@ class AbnAmroDescription implements SpecificInterface
}
/**
* Parses the current description in TRTP format
* Parses the current description in TRTP format.
*
* @return bool true if the description is TRTP format, false otherwise
*/
@@ -222,7 +218,7 @@ class AbnAmroDescription implements SpecificInterface
// Set a new description for the current transaction. If none was given
// set the description to type, name and reference
$this->row[7] = $newDescription;
if (strlen($newDescription) === 0) {
if (0 === strlen($newDescription)) {
$this->row[7] = sprintf('%s - %s (%s)', $type, $name, $reference);
}
}

View File

@@ -1,7 +1,7 @@
<?php
/**
* IngDescription.php
* Copyright (C) 2016 https://github.com/tomwerf
* Copyright (C) 2016 https://github.com/tomwerf.
*
* This file is part of Firefly III.
*
@@ -18,13 +18,12 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
/**
* Class IngDescription
* Class IngDescription.
*
* Parses the description from CSV files for Ing bank accounts.
*
@@ -32,12 +31,10 @@ namespace FireflyIII\Import\Specifics;
* 'Incasso' the Name of Opposing account the Opposing IBAN number are in the
* Description. This class will remove them, and add Name in description by
* 'Betaalautomaat' so those are easily recognizable
*
* @package FireflyIII\Import\Specifics
*/
class IngDescription implements SpecificInterface
{
/** @var array */
/** @var array */
public $row;
/**
@@ -84,7 +81,7 @@ class IngDescription implements SpecificInterface
/**
* Add the Opposing name from cell 1 in the description for Betaalautomaten
* Otherwise the description is only: 'Pasvolgnr:<nr> <date> Transactie:<NR> Term:<nr>'
* Otherwise the description is only: 'Pasvolgnr:<nr> <date> Transactie:<NR> Term:<nr>'.
*
* @return bool true
*/
@@ -97,7 +94,7 @@ class IngDescription implements SpecificInterface
/**
* Remove IBAN number out of the description
* Default description of Description is: Naam: <OPPOS NAME> Omschrijving: <DESCRIPTION> IBAN: <OPPOS IBAN NR>
* Default description of Description is: Naam: <OPPOS NAME> Omschrijving: <DESCRIPTION> IBAN: <OPPOS IBAN NR>.
*
* @return bool true
*/
@@ -110,7 +107,7 @@ class IngDescription implements SpecificInterface
}
/**
* Remove name from the description (Remove everything before the description incl the word 'Omschrijving' )
* Remove name from the description (Remove everything before the description incl the word 'Omschrijving' ).
*
* @return bool true
*/

View File

@@ -18,19 +18,15 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
/**
* Class PresidentsChoice
*
* @package FireflyIII\Import\Specifics
* Class PresidentsChoice.
*/
class PresidentsChoice implements SpecificInterface
{
/**
* @return string
*/
@@ -56,7 +52,7 @@ class PresidentsChoice implements SpecificInterface
{
// first, if column 2 is empty and 3 is not, do nothing.
// if column 3 is empty and column 2 is not, move amount to column 3, *-1
if (isset($row[3]) && strlen($row[3]) === 0) {
if (isset($row[3]) && 0 === strlen($row[3])) {
$row[3] = bcmul($row[2], '-1');
}
if (isset($row[1])) {

View File

@@ -18,7 +18,6 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
@@ -26,9 +25,7 @@ namespace FireflyIII\Import\Specifics;
use Log;
/**
* Class RabobankDescription
*
* @package FireflyIII\Import\Specifics
* Class RabobankDescription.
*/
class RabobankDescription implements SpecificInterface
{

View File

@@ -21,22 +21,19 @@
/**
* snsDescription.php
* Author 2017 hugovanduijn@gmail.com
* Author 2017 hugovanduijn@gmail.com.
*
* This software may be modified and distributed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International License.
*
* See the LICENSE file for details.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
/**
* Class SnsDescription
*
* @package FireflyIII\Import\Specifics
* Class SnsDescription.
*/
class SnsDescription implements SpecificInterface
{

View File

@@ -18,15 +18,12 @@
* You should have received a copy of the GNU General Public License
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
*/
declare(strict_types=1);
namespace FireflyIII\Import\Specifics;
/**
* Interface SpecificInterface
*
* @package FireflyIII\Import\Specifics
* Interface SpecificInterface.
*/
interface SpecificInterface
{