<commit_before><?php
/**
 * ImportEntry.php
 * Copyright (C) 2016 <EMAIL>
 *
 * 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;

use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;

/**
 * Class ImportEntry
 *
 * @package FireflyIII\Import
 */
class ImportEntry
{
    /** @var array */
    public $certain = [];
    /** @var  Collection */
    public $errors;
    /** @var  string */
    public $externalID;
    /** @var  array */
    public $fields = [];
    /** @var  string */
    public $hash;
    /** @var  User */
    public $user;
    /** @var bool */
    public $valid = true;
    /** @var  int */
    private $amountMultiplier = 0;

    /** @var array */
    private $validFields
        = ['amount',
           'date-transaction',
           'date-interest',
           'date-book',
           'description',
           'date-process',
           'transaction-type',
           'currency', 'asset-account', 'opposing-account', 'bill', 'budget', 'category', 'tags'];

    /**
     * ImportEntry constructor.
     */
    public function __construct()
    {
        /** @var string $value */
        foreach ($this->validFields as $value) {
            $this->fields[$value]  = null;
            $this->certain[$value] = 0;
        }
        $this->errors = new Collection;

    }

    /**
     * @param string $role
     * @param int    $certainty
     * @param        $convertedValue
     *
     * @throws FireflyException
     */
    public function importValue(string $role, int $certainty, $convertedValue)
    {
        switch ($role) {
            default:
                Log::error('Import entry cannot handle object.', ['role' => $role]);
                throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
            case 'hash':
                $this->hash = $convertedValue;

                return;
            case 'amount':
                /*
                 * Easy enough.
                 */
                $this->setFloat('amount', $convertedValue, $certainty);
                $this->applyMultiplier('amount'); // if present.

                return;
            case 'account-id':
            case 'account-iban':
            case 'account-name':
                $this->setObject('asset-account', $convertedValue, $certainty);
                break;
            case 'account-number':
                
                break;
            case 'opposing-number':
            case 'opposing-iban':
            case 'opposing-id':
            case 'opposing-name':
                $this->setObject('opposing-account', $convertedValue, $certainty);
                break;
            case 'bill-id':
            case 'bill-name':
                $this->setObject('bill', $convertedValue, $certainty);
                break;
            case 'budget-id':
            case 'budget-name':
                $this->setObject('budget', $convertedValue, $certainty);
                break;
            case 'category-id':
            case 'category-name':
                $this->setObject('category', $convertedValue, $certainty);
                break;
            case 'currency-code':
            case 'currency-id':
            case 'currency-name':
            case 'currency-symbol':
                $this->setObject('currency', $convertedValue, $certainty);
                break;
            case 'date-transaction':
                $this->setDate('date-transaction', $convertedValue, $certainty);
                break;<commit_msg>This should fix account-number.<commit_after><?php
/**
 * ImportEntry.php
 * Copyright (C) 2016 <EMAIL>
 *
 * 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;

use Carbon\Carbon;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\User;
use Illuminate\Support\Collection;
use Log;

/**
 * Class ImportEntry
 *
 * @package FireflyIII\Import
 */
class ImportEntry
{
    /** @var array */
    public $certain = [];
    /** @var  Collection */
    public $errors;
    /** @var  string */
    public $externalID;
    /** @var  array */
    public $fields = [];
    /** @var  string */
    public $hash;
    /** @var  User */
    public $user;
    /** @var bool */
    public $valid = true;
    /** @var  int */
    private $amountMultiplier = 0;

    /** @var array */
    private $validFields
        = ['amount',
           'date-transaction',
           'date-interest',
           'date-book',
           'description',
           'date-process',
           'transaction-type',
           'currency', 'asset-account', 'opposing-account', 'bill', 'budget', 'category', 'tags'];

    /**
     * ImportEntry constructor.
     */
    public function __construct()
    {
        /** @var string $value */
        foreach ($this->validFields as $value) {
            $this->fields[$value]  = null;
            $this->certain[$value] = 0;
        }
        $this->errors = new Collection;

    }

    /**
     * @param string $role
     * @param int    $certainty
     * @param        $convertedValue
     *
     * @throws FireflyException
     */
    public function importValue(string $role, int $certainty, $convertedValue)
    {
        switch ($role) {
            default:
                Log::error('Import entry cannot handle object.', ['role' => $role]);
                throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
            case 'hash':
                $this->hash = $convertedValue;

                return;
            case 'amount':
                /*
                 * Easy enough.
                 */
                $this->setFloat('amount', $convertedValue, $certainty);
                $this->applyMultiplier('amount'); // if present.

                return;
            case 'account-id':
            case 'account-iban':
            case 'account-name':
            case 'account-number':
                $this->setObject('asset-account', $convertedValue, $certainty);
                break;
            case 'opposing-number':
            case 'opposing-iban':
            case 'opposing-id':
            case 'opposing-name':
                $this->setObject('opposing-account', $convertedValue, $certainty);
                break;
            case 'bill-id':
            case 'bill-name':
                $this->setObject('bill', $convertedValue, $certainty);
                break;
            case 'budget-id':
            case 'budget-name':
                $this->setObject('budget', $convertedValue, $certainty);
                break;
            case 'category-id':
            case 'category-name':
                $this->setObject('category', $convertedValue, $certainty);
                break;
            case 'currency-code':
            case 'currency-id':
            case 'currency-name':
            case 'currency-symbol':
                $this->setObject('currency', $convertedValue, $certainty);
                break;
            case 'date-transaction':
                $this->setDate('date-transaction', $convertedValue, $certainty);
                break;
{'fraction_non_alphanumeric': 0.13465636654235483, 'fraction_numerical': 0.002397442727757059, 'mean_word_length': 1.6741452991452992, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7526490', 'n_tokens_mistral': 2085, 'n_tokens_neox': 1984, 'n_words': 487}