Cambio en nombre de metodo y uso de valor maximo para UF
This commit is contained in:
@ -27,7 +27,7 @@ class Valor
|
||||
public function toPesos(string $value, null|string|DateTimeInterface $date = null, bool $force = false): int
|
||||
{
|
||||
$date = $this->getDateTime($date);
|
||||
if ($this->isFloat($value) or $force) {
|
||||
if ($this->inUF($value) or $force) {
|
||||
return round($value * $this->ufService->get($date));
|
||||
}
|
||||
return (int) $value;
|
||||
@ -35,7 +35,7 @@ class Valor
|
||||
public function toUF(string $value, null|string|DateTimeInterface $date = null, bool $force = false): float
|
||||
{
|
||||
$date = $this->getDateTime($date);
|
||||
if ($this->isFloat($value) and !$force) {
|
||||
if ($this->inUF($value) and !$force) {
|
||||
return (float) $value;
|
||||
}
|
||||
return $value / $this->ufService->get($date);
|
||||
@ -101,9 +101,12 @@ class Valor
|
||||
{
|
||||
return (float) str_replace(',', '', $value);
|
||||
}
|
||||
protected function isFloat(string|int|float $value): bool
|
||||
protected function inUF(string|int|float $value, float $check = 10000): bool
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
if ($value >= $check) { // Valor arbitrario mayor que el cual no es UF
|
||||
return false;
|
||||
}
|
||||
return is_float($value);
|
||||
}
|
||||
$cleaned = $this->clean($value);
|
||||
|
Reference in New Issue
Block a user