decimal() public static method

public static decimal ( $value, $places = null )
コード例 #1
0
ファイル: ValidationTest.php プロジェクト: aichelman/StudyUp
 /**
  * testDecimalCustomRegex method
  *
  * @return void
  */
 public function testDecimalCustomRegex()
 {
     $this->assertTrue(Validation::decimal('1.54321', null, '/^[-+]?[0-9]+(\\.[0-9]+)?$/s'));
     $this->assertFalse(Validation::decimal('.54321', null, '/^[-+]?[0-9]+(\\.[0-9]+)?$/s'));
 }
コード例 #2
0
ファイル: ValidationTest.php プロジェクト: alvaroziqar/galei
 /**
  * Test localized floats with decimal.
  *
  * @return void
  */
 public function testDecimalLocaleSet()
 {
     $this->skipIf(DS === '\\', 'The locale is not supported in Windows and affects other tests.');
     $restore = setlocale(LC_NUMERIC, 0);
     $this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
     $this->assertTrue(Validation::decimal(1.54), '1.54 should be considered a valid float');
     $this->assertTrue(Validation::decimal('1.54'), '"1.54" should be considered a valid float');
     $this->assertTrue(Validation::decimal(12345.67), '12345.67 should be considered a valid float');
     $this->assertTrue(Validation::decimal('12,345.67'), '"12,345.67" should be considered a valid float');
     setlocale(LC_NUMERIC, $restore);
 }
コード例 #3
0
 /**
  * @testdox decimal should return false to numbers with missing decimal places
  */
 public function testInvalidDecimalWithJustPoint()
 {
     $value = '42.';
     $this->assertFalse(Validation::decimal($value));
 }