firefly-iii/app/Import/ImportEntry.php

64 lines
1.4 KiB
PHP
Raw Normal View History

2016-07-15 15:26:08 -05:00
<?php
/**
* ImportEntry.php
* Copyright (C) 2016 thegrumpydictator@gmail.com
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
declare(strict_types = 1);
namespace FireflyIII\Import;
use FireflyIII\Exceptions\FireflyException;
use Log;
2016-07-15 15:26:08 -05:00
/**
* Class ImportEntry
*
* @package FireflyIII\Import
*/
class ImportEntry
{
public $amount;
2016-07-15 15:26:08 -05:00
2016-07-30 09:29:04 -05:00
2016-07-15 15:26:08 -05:00
/**
* @param string $role
* @param string $value
* @param int $certainty
* @param $convertedValue
2016-07-15 15:26:08 -05:00
*
* @throws FireflyException
*/
public function importValue(string $role, string $value, int $certainty, $convertedValue)
2016-07-15 15:26:08 -05:00
{
2016-07-30 09:29:04 -05:00
Log::debug('Going to import', ['role' => $role, 'value' => $value, 'certainty' => $certainty]);
2016-07-15 15:26:08 -05:00
switch ($role) {
default:
Log::error('Import entry cannot handle object.', ['role' => $role]);
throw new FireflyException('Import entry cannot handle object of type "' . $role . '".');
break;
case 'amount':
2016-07-30 09:29:04 -05:00
/*
* Easy enough.
*/
$this->setAmount($convertedValue);
2016-07-15 15:26:08 -05:00
2016-07-30 09:29:04 -05:00
return;
2016-07-15 15:26:08 -05:00
}
}
/**
* @param float $amount
*/
private function setAmount(float $amount)
{
$this->amount = $amount;
}
2016-07-15 15:26:08 -05:00
}