original_string: public static function decimal($check, $places = null, $regex = null)
      {
          if ($regex === null) {
              $lnum = '[0-9]+';
              $dnum = "[0-9]*[\.]{$lnum}";
              $sign = '[+-]?';
              $exp = "(?:[eE]{$sign}{$lnum})?";
  
              if ($places === null) {
                  $regex = "/^{$sign}(?:{$lnum}|{$dnum}){$exp}$/";
              } elseif ($places === true) {
                  if (is_float($check) && floor($check) === $check) {
                      $check = sprintf('%.1f', $check);
                  }
                  $regex = "/^{$sign}{$dnum}{$exp}$/";
              } elseif (is_numeric($places)) {
                  $places = '[0-9]{' . $places . '}';
                  $dnum = "(?:[0-9]*[\.]{$places}|{$lnum}[\.]{$places})";
                  $regex = "/^{$sign}{$dnum}{$exp}$/";
              }
          }
  
          // account for localized floats.
          $locale = ini_get('intl.default_locale') ?: static::DEFAULT_LOCALE;
          $formatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
          $decimalPoint = $formatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
          $groupingSep = $formatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
  
          $check = str_replace([$groupingSep, $decimalPoint], ['', '.'], $check);
  
          return static::_check($check, $regex);
      }
code: public static function decimal($check, $places = null, $regex = null)
      {
          if ($regex === null) {
              $lnum = '[0-9]+';
              $dnum = "[0-9]*[\.]{$lnum}";
              $sign = '[+-]?';
              $exp = "(?:[eE]{$sign}{$lnum})?";
  
              if ($places === null) {
                  $regex = "/^{$sign}(?:{$lnum}|{$dnum}){$exp}$/";
              } elseif ($places === true) {
                  if (is_float($check) && floor($check) === $check) {
                      $check = sprintf('%.1f', $check);
                  }
                  $regex = "/^{$sign}{$dnum}{$exp}$/";
              } elseif (is_numeric($places)) {
                  $places = '[0-9]{' . $places . '}';
                  $dnum = "(?:[0-9]*[\.]{$places}|{$lnum}[\.]{$places})";
                  $regex = "/^{$sign}{$dnum}{$exp}$/";
              }
          }
  
          // account for localized floats.
          $locale = ini_get('intl.default_locale') ?: static::DEFAULT_LOCALE;
          $formatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
          $decimalPoint = $formatter->getSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL);
          $groupingSep = $formatter->getSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL);
  
          $check = str_replace([$groupingSep, $decimalPoint], ['', '.'], $check);
  
          return static::_check($check, $regex);
      }
code_tokens: public static function decimal ( $ check , $ places = null , $ regex = null ) { if ( $ regex === null ) { $ lnum = '[0-9]+' ; $ dnum = "[0-9]*[\.]{$lnum}" ; $ sign = '[+-]?' ; $ exp = "(?:[eE]{$sign}{$lnum})?" ; if ( $ places === null ) { $ regex = "/^{$sign}(?:{$lnum}|{$dnum}){$exp}$/" ; } elseif ( $ places === true ) { if ( is_float ( $ check ) && floor ( $ check ) === $ check ) { $ check = sprintf ( '%.1f' , $ check ) ; } $ regex = "/^{$sign}{$dnum}{$exp}$/" ; } elseif ( is_numeric ( $ places ) ) { $ places = '[0-9]{' . $ places . '}' ; $ dnum = "(?:[0-9]*[\.]{$places}|{$lnum}[\.]{$places})" ; $ regex = "/^{$sign}{$dnum}{$exp}$/" ; } } // account for localized floats. $ locale = ini_get ( 'intl.default_locale' ) ? : static :: DEFAULT_LOCALE ; $ formatter = new NumberFormatter ( $ locale , NumberFormatter :: DECIMAL ) ; $ decimalPoint = $ formatter -> getSymbol ( NumberFormatter :: DECIMAL_SEPARATOR_SYMBOL ) ; $ groupingSep = $ formatter -> getSymbol ( NumberFormatter :: GROUPING_SEPARATOR_SYMBOL ) ; $ check = str_replace ( [ $ groupingSep , $ decimalPoint ] , [ '' , '.' ] , $ check ) ; return static :: _check ( $ check , $ regex ) ; }
docstring: Checks that a value is a valid decimal. Both the sign and exponent are optional.
  
  Valid Places:
  
  - null => Any number of decimal places, including none. The '.' is not required.
  - true => Any number of decimal places greater than 0, or a float|double. The '.' is required.
  - 1..N => Exactly that many number of decimal places. The '.' is required.
  
  @param float $check The value the test for decimal.
  @param int|bool|null $places Decimal places.
  @param string|null $regex If a custom regular expression is used, this is the only validation that will occur.
  @return bool Success
docstring_tokens: Checks that a value is a valid decimal . Both the sign and exponent are optional .