mirror of
https://github.com/Bubka/2FAuth.git
synced 2024-11-26 02:04:52 +01:00
Add support of floats to SettingService
This commit is contained in:
parent
ead31fef87
commit
7137f0e7a1
@ -140,7 +140,9 @@ private function replaceBoolean(mixed $value)
|
||||
*/
|
||||
private function restoreType(mixed $value)
|
||||
{
|
||||
$value = is_numeric($value) ? (int) $value : $value;
|
||||
if (is_numeric($value)) {
|
||||
$value = is_float($value + 0) ? (float) $value : (int) $value;
|
||||
}
|
||||
|
||||
if ($value === '{{}}') {
|
||||
return false;
|
||||
|
@ -37,6 +37,8 @@ class SettingServiceTest extends FeatureTestCase
|
||||
|
||||
private const SETTING_VALUE_INT = 10;
|
||||
|
||||
private const SETTING_VALUE_FLOAT = 10.5;
|
||||
|
||||
private const ACCOUNT = 'account';
|
||||
|
||||
private const SERVICE = 'service';
|
||||
@ -132,6 +134,19 @@ public function test_get_int_setting_returns_int()
|
||||
$this->assertIsInt($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function test_get_float_setting_returns_float()
|
||||
{
|
||||
Settings::set(self::SETTING_NAME, self::SETTING_VALUE_FLOAT);
|
||||
|
||||
$value = Settings::get(self::SETTING_NAME);
|
||||
|
||||
$this->assertEquals(self::SETTING_VALUE_FLOAT, $value);
|
||||
$this->assertIsFloat($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user