firefly-iii/app/Import/Specifics/RabobankDescription.php

79 lines
2.3 KiB
PHP
Raw Normal View History

2016-06-24 07:24:34 -05:00
<?php
/**
* RabobankDescription.php
2017-10-21 01:40:00 -05:00
* Copyright (c) 2017 thegrumpydictator@gmail.com
2016-06-24 07:24:34 -05:00
*
2017-10-21 01:40:00 -05:00
* This file is part of Firefly III.
*
2017-10-21 01:40:00 -05:00
* Firefly III is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Firefly III is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
2017-12-17 07:44:05 -06:00
* along with Firefly III. If not, see <http://www.gnu.org/licenses/>.
2016-06-24 07:24:34 -05:00
*/
declare(strict_types=1);
2016-06-24 07:24:34 -05:00
namespace FireflyIII\Import\Specifics;
2016-08-12 02:27:09 -05:00
use Log;
2016-06-24 07:24:34 -05:00
/**
2017-11-15 05:25:49 -06:00
* Class RabobankDescription.
2016-06-24 07:24:34 -05:00
*/
class RabobankDescription implements SpecificInterface
{
2016-08-12 02:27:09 -05:00
/**
* @return string
*/
2016-08-12 08:10:03 -05:00
public static function getDescription(): string
2016-08-12 02:27:09 -05:00
{
return 'Fixes possible problems with Rabobank descriptions.';
}
2016-06-24 07:24:34 -05:00
/**
* @return string
*/
2016-08-12 08:10:03 -05:00
public static function getName(): string
2016-06-24 07:24:34 -05:00
{
return 'Rabobank description';
}
/**
2016-08-12 02:27:09 -05:00
* @param array $row
*
* @return array
2016-06-24 07:24:34 -05:00
*/
2016-08-12 02:27:09 -05:00
public function run(array $row): array
2016-06-24 07:24:34 -05:00
{
$row = array_values($row);
Log::debug(sprintf('Now in RabobankSpecific::run(). Row has %d columns', count($row)));
$oppositeAccount = isset($row[5]) ? trim($row[5]) : '';
$oppositeName = isset($row[6]) ? trim($row[6]) : '';
$alternateName = isset($row[10]) ? trim($row[10]) : '';
2016-08-12 02:27:09 -05:00
if (strlen($oppositeAccount) < 1 && strlen($oppositeName) < 1) {
Log::debug(
sprintf(
'Rabobank specific: Opposite account and opposite name are' .
2017-11-15 03:52:29 -06:00
' both empty. Will use "%s" (from description) instead',
$alternateName
2016-08-12 02:27:09 -05:00
)
);
$row[6] = $alternateName;
$row[10] = '';
2017-09-09 00:03:43 -05:00
}
if (!(strlen($oppositeAccount) < 1 && strlen($oppositeName) < 1)) {
2016-08-12 02:27:09 -05:00
Log::debug('Rabobank specific: either opposite account or name are filled.');
}
return $row;
2016-06-24 07:24:34 -05:00
}
2016-08-12 08:10:03 -05:00
}