当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale_Format::isInteger方法代码示例

本文整理汇总了PHP中Zend_Locale_Format::isInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Format::isInteger方法的具体用法?PHP Zend_Locale_Format::isInteger怎么用?PHP Zend_Locale_Format::isInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale_Format的用法示例。


在下文中一共展示了Zend_Locale_Format::isInteger方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a valid integer
  *
  * @param  string|integer $value
  * @return boolean
  */
 public function isValid($value)
 {
     if (!is_string($value) && !is_int($value) && !is_float($value)) {
         $this->_error(self::INVALID);
         return false;
     }
     if (is_int($value)) {
         return true;
     }
     $this->_setValue($value);
     if ($this->_locale === null) {
         $locale = localeconv();
         $valueFiltered = str_replace($locale['decimal_point'], '.', $value);
         $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
         if (strval(intval($valueFiltered)) != $valueFiltered) {
             $this->_error(self::NOT_INT);
             return false;
         }
     } else {
         try {
             if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
                 $this->_error(self::NOT_INT);
                 return false;
             }
         } catch (Zend_Locale_Exception $e) {
             $this->_error(self::NOT_INT);
             return false;
         }
     }
     return true;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:39,代码来源:Int.php

示例2: isValid

 /**
  * Defined by Zend_Validate_Interface
  *
  * Returns true if and only if $value is a valid integer
  *
  * @param  string $value
  * @return boolean
  */
 public function isValid($value)
 {
     $valueString = (string) $value;
     $this->_setValue($valueString);
     if (is_bool($value)) {
         $this->_error();
         return false;
     }
     try {
         if (!Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
             $this->_error();
             return false;
         }
     } catch (Zend_Locale_Exception $e) {
         $this->_error();
         return false;
     }
     return true;
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:27,代码来源:Int.php

示例3: testIsInteger

 /**
  * test isInteger
  * expected boolean
  */
 public function testIsInteger()
 {
     $this->assertTrue( Zend_Locale_Format::isInteger('-1.234.567,12345',  array('locale' => 'de_AT')));
     $this->assertFalse(Zend_Locale_Format::isInteger('textwithoutnumber', array('locale' => 'de_AT')));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:FormatTest.php

示例4: testIsInteger

 /**
  * test isInteger
  * expected boolean
  */
 public function testIsInteger()
 {
     $this->assertEquals(Zend_Locale_Format::isInteger('-1.234.567,12345', array('locale' => 'de_AT')), TRUE, "TRUE expected");
     $this->assertEquals(Zend_Locale_Format::isInteger('textwithoutnumber', array('locale' => 'de_AT')), FALSE, "FALSE expected");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:FormatTest.php

示例5: testShortNotation

 public function testShortNotation()
 {
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getNumber(',12345', $options));
     $this->assertEquals('0,75', Zend_Locale_Format::toNumber(0.75, array('locale' => 'de_DE', 'precision' => 2)));
     $this->assertTrue(Zend_Locale_Format::isNumber(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(0.12345));
     $options = array('locale' => 'de');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0.12345, Zend_Locale_Format::getFloat(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $options = array('locale' => 'ar_QA');
     $this->assertEquals('0,12345', Zend_Locale_Format::toFloat(0.12345, $options));
     $this->assertTrue(Zend_Locale_Format::isFloat(',12345', array('locale' => 'de_AT')));
     $this->assertEquals(0, Zend_Locale_Format::getInteger(0.1234567));
     $options = array('locale' => 'de');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $options = array('locale' => 'de_AT');
     $this->assertEquals(0, Zend_Locale_Format::getInteger(',12345', $options));
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.123, array('locale' => 'de')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0', Zend_Locale_Format::toInteger(0.12345, $options));
     $this->assertFalse(Zend_Locale_Format::isInteger(',12345', array('locale' => 'de_AT')));
     $options = array('locale' => 'de_AT');
     $this->assertEquals('0,567', Zend_Locale_Format::toNumber(0.5669999999999999, $options));
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:31,代码来源:FormatTest.php

示例6: testIsIntegerFailed

 /**
  * test if isNumberFailed
  * expected boolean
  */
 public function testIsIntegerFailed()
 {
     $value = Zend_Locale_Format::isInteger('textwithoutnumber', 'de_AT');
     $this->assertEquals($value, FALSE, "FALSE expected");
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:9,代码来源:FormatTest.php

示例7: isInteger

 /** Checks if a given string is valid representation of an integer in the current locale.
  * @return bool
  * @example http://www.concrete5.org/documentation/how-tos/developers/formatting-numbers/ See the Formatting numbers how-to for more details
  */
 public function isInteger($string)
 {
     return Zend_Locale_Format::isInteger($string, array('locale' => $this->getZendLocale()));
 }
开发者ID:ojalehto,项目名称:concrete5-legacy,代码行数:8,代码来源:number.php

示例8: testIsIntegerForLocaleZhHK

 /**
  * @group GH-430
  */
 public function testIsIntegerForLocaleZhHK()
 {
     $this->assertTrue(Zend_Locale_Format::isInteger('1', array('locale' => 'zh_HK')));
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:7,代码来源:FormatTest.php

示例9: filter

 /**
  * Defined by Zend_Filter_Interface
  *
  * Normalizes the given input
  *
  * @param  string $value Value to normalized
  * @return string|array The normalized value
  */
 public function filter($value)
 {
     if ($this->_options['date_format'] === null && strpos($value, ':') !== false) {
         // Special case, no date format specified, detect time input
         return Zend_Locale_Format::getTime($value, $this->_options);
     } else {
         if (Zend_Locale_Format::checkDateFormat($value, $this->_options)) {
             // Detect date or time input
             return Zend_Locale_Format::getDate($value, $this->_options);
         } else {
             if ($this->_options['precision'] === 0 && Zend_Locale_Format::isInteger($value, $this->_options)) {
                 // Detect integer
                 return Zend_Locale_Format::getInteger($value, $this->_options);
             } else {
                 if ($this->_options['precision'] === null && Zend_Locale_Format::isFloat($value, $this->_options)) {
                     // Detect float
                     return Zend_Locale_Format::getFloat($value, $this->_options);
                 } else {
                     if (Zend_Locale_Format::isNumber($value, $this->_options)) {
                         // Detect all other numbers
                         return Zend_Locale_Format::getNumber($value, $this->_options);
                     }
                 }
             }
         }
     }
     return $value;
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:36,代码来源:LocalizedToNormalized.php

示例10: isBillrunKey

 public static function isBillrunKey($billrun_key)
 {
     return is_string($billrun_key) && Zend_Locale_Format::isInteger($billrun_key) && strlen($billrun_key) == 6 && substr($billrun_key, 4, 2) >= '01' && substr($billrun_key, 4, 2) <= '12';
 }
开发者ID:ngchie,项目名称:system,代码行数:4,代码来源:Util.php


注:本文中的Zend_Locale_Format::isInteger方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。