Various code cleanup.

This commit is contained in:
James Cole
2017-12-22 18:32:43 +01:00
parent f13a93348f
commit 8bd76d1ff0
188 changed files with 383 additions and 396 deletions

View File

@@ -171,6 +171,7 @@ class SpectreConfigurator implements ConfiguratorInterface
break;
case !$this->job->configuration['has-input-mandatory']:
$class = InputMandatory::class;
// no break
default:
break;
}

View File

@@ -70,7 +70,7 @@ class Amount implements ConverterInterface
if (is_null($decimal)) {
Log::debug('Decimal is still NULL, probably number with >2 decimals. Search for a dot.');
$res = strrpos($value, '.');
if (!($res === false)) {
if (!(false === $res)) {
// blandly assume this is the one.
Log::debug(sprintf('Searched from the left for "." in amount "%s", assume this is the decimal sign.', $value));
$decimal = '.';

View File

@@ -70,6 +70,7 @@ class CsvProcessor implements FileProcessorInterface
* Does the actual job.
*
* @return bool
*
* @throws \League\Csv\Exception
*/
public function run(): bool
@@ -160,6 +161,7 @@ class CsvProcessor implements FileProcessorInterface
/**
* @return Iterator
*
* @throws \League\Csv\Exception
* @throws \League\Csv\Exception
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
@@ -174,7 +176,7 @@ class CsvProcessor implements FileProcessorInterface
$delimiter = "\t";
}
$reader->setDelimiter($delimiter);
if($config['has-headers']) {
if ($config['has-headers']) {
$reader->setHeaderOffset(0);
}
$results = $reader->getRecords();
@@ -279,6 +281,7 @@ class CsvProcessor implements FileProcessorInterface
* @param array $array
*
* @return bool
*
* @throws FireflyException
*/
private function rowAlreadyImported(array $array): bool

View File

@@ -337,4 +337,4 @@ class BunqPrerequisites implements PrerequisitesInterface
return $deviceServerId;
}
}
}

View File

@@ -92,5 +92,4 @@ class FilePrerequisites implements PrerequisitesInterface
{
return new MessageBag;
}
}

View File

@@ -28,8 +28,6 @@ use Illuminate\Support\MessageBag;
/**
* Interface PrerequisitesInterface
*
* @package FireflyIII\Import\Prerequisites
*/
interface PrerequisitesInterface
{

View File

@@ -27,8 +27,6 @@ use Illuminate\Support\Collection;
/**
* Interface RoutineInterface
*
* @package FireflyIII\Import\Routine
*/
interface RoutineInterface
{
@@ -58,6 +56,4 @@ interface RoutineInterface
* @return mixed
*/
public function setJob(ImportJob $job);
}

View File

@@ -25,9 +25,9 @@ namespace FireflyIII\Import\Routine;
use FireflyIII\Models\ImportJob;
use FireflyIII\Services\Spectre\Object\Customer;
use FireflyIII\Services\Spectre\Request\NewCustomerRequest;
use Preferences;
use Illuminate\Support\Collection;
use Log;
use Preferences;
/**
* Class FileRoutine
@@ -91,7 +91,6 @@ class SpectreRoutine implements RoutineInterface
// create customer if user does not have one:
$customer = $this->getCustomer();
return true;
}
@@ -113,7 +112,6 @@ class SpectreRoutine implements RoutineInterface
echo '<pre>';
print_r($newCustomerRequest->getCustomer());
exit;
}
/**
@@ -128,6 +126,4 @@ class SpectreRoutine implements RoutineInterface
var_dump($preference->data);
exit;
}
}

View File

@@ -127,7 +127,7 @@ class IngDescription implements SpecificInterface
private function copyDescriptionToOpposite(): void
{
$search = ['Naar Oranje Spaarrekening ', 'Afschrijvingen'];
if (strlen($this->row[3]) === 0) {
if (0 === strlen($this->row[3])) {
$this->row[3] = trim(str_ireplace($search, '', $this->row[8]));
}
}

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;

View File

@@ -45,11 +45,11 @@ class ImportStorage
public $errors;
/** @var Collection */
public $journals;
/** @var BillRepositoryInterface */
/** @var BillRepositoryInterface */
protected $billRepository; // yes, hard coded
/** @var Collection */
protected $bills;
/** @var int */
/** @var int */
protected $defaultCurrencyId = 1;
/** @var ImportJob */
protected $job;
@@ -96,11 +96,11 @@ class ImportStorage
$config = $job->configuration;
$this->applyRules = $config['apply_rules'] ?? false;
$this->matchBills = $config['match_bills'] ?? false;
if ($this->applyRules === true) {
if (true === $this->applyRules) {
Log::debug('applyRules seems to be true, get the rules.');
$this->rules = $this->getRules();
}
if ($this->matchBills === true) {
if (true === $this->matchBills) {
Log::debug('matchBills seems to be true, get the bills');
$this->bills = $this->getBills();
$this->billRepository = app(BillRepositoryInterface::class);
@@ -226,22 +226,22 @@ class ImportStorage
$this->job->addStepsDone(1);
// run rules if config calls for it:
if ($this->applyRules === true) {
if (true === $this->applyRules) {
Log::info('Will apply rules to this journal.');
$this->applyRules($journal);
}
if (!($this->applyRules === true)) {
if (!(true === $this->applyRules)) {
Log::info('Will NOT apply rules to this journal.');
}
// match bills if config calls for it.
if ($this->matchBills === true) {
if (true === $this->matchBills) {
//$this->/applyRules($journal);
Log::info('Cannot match bills (yet).');
$this->matchBills($journal);
}
if (!($this->matchBills === true)) {
if (!(true === $this->matchBills)) {
Log::info('Cannot match bills (yet), but do not have to.');
}

View File

@@ -93,8 +93,9 @@ trait ImportSupport
*/
protected function matchBills(TransactionJournal $journal): bool
{
if(!is_null($journal->bill_id)) {
if (!is_null($journal->bill_id)) {
Log::debug('Journal is already linked to a bill, will not scan.');
return true;
}
if ($this->bills->count() > 0) {
@@ -264,6 +265,7 @@ trait ImportSupport
*
* @return string
*x
*
* @throws FireflyException
*
* @see ImportSupport::getOpposingAccount()
@@ -412,6 +414,7 @@ trait ImportSupport
* @param array $parameters
*
* @return TransactionJournal
*
* @throws FireflyException
*/
private function storeJournal(array $parameters): TransactionJournal