test string val

This commit is contained in:
2022-03-31 16:41:00 +02:00
parent a29ee0d5b7
commit 6b005cb5b6
3 changed files with 17 additions and 12 deletions
+2
View File
@@ -25,6 +25,8 @@ class Crypto extends Main
if ($item->getValue() == 0) {
continue;
}
if ($item->getCurrency() === "BTC")
dd($item,$item->getValueCrypto());
// if (!isset($sum[$item->getCurrency()])) {
// $sum[$item->getCurrency()] = [];
// if (!isset($sum[$item->getCurrency()][$item->getDateTime()->format("Y-m-d")])){
+4 -6
View File
@@ -40,12 +40,10 @@ class Main
$obj = new MainObject();
foreach ($names as $key => $name) {
if ($name === "setValue") {
// if ($datum[$key]!=="0,00") dd();
$data = $datum[$key];
if (is_string($data)) {
$data = strtr($data,",",".");
}
$datum[$key] = floatval($data);
$data = "$datum[$key]";
$data = str_replace(",","",$data);
$data = str_replace(".","",$data);
$datum[$key] = $data;
}
if ($name === "setDateTime") {
$datum[$key] = new \DateTime($datum[$key]);
+11 -6
View File
@@ -8,7 +8,7 @@ class MainObject
{
private \DateTime $dateTime;
private string $desc;
private float $value;
private string $value;
private string $currency;
private ?string $realCurrency=null;
private float $realValue=0;
@@ -79,17 +79,17 @@ class MainObject
}
/**
* @return float
* @return int
*/
public function getValue(): float
public function getValue(): string
{
return $this->value;
}
/**
* @param float $value
* @param int $value
*/
public function setValue(float $value): void
public function setValue(string $value): void
{
$this->value = $value;
}
@@ -110,7 +110,7 @@ class MainObject
$this->currency = $currency;
}
public function addValue(float $val) : void
public function addValue(int $val) : void
{
$this->value += $val;
}
@@ -132,4 +132,9 @@ class MainObject
{
return $this->price;
}
public function getValueCrypto() : float
{
return intval($this->value) / 100000000;
}
}