當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DataValidator::getZeroPaddedValue方法代碼示例

本文整理匯總了PHP中DataValidator::getZeroPaddedValue方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataValidator::getZeroPaddedValue方法的具體用法?PHP DataValidator::getZeroPaddedValue怎麽用?PHP DataValidator::getZeroPaddedValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DataValidator的用法示例。


在下文中一共展示了DataValidator::getZeroPaddedValue方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testGetZeroPaddedValue

 /**
  * Oh Shit: It's an actual simple unit test!
  * @covers DataValidator::getZeroPaddedValue()
  */
 public function testGetZeroPaddedValue()
 {
     //make sure that it works in the two main categories of ways it should work
     $this->assertEquals('00123', DataValidator::getZeroPaddedValue('123', 5), "getZeroPaddedValue does not properly pad out a value in the simplest case");
     $this->assertEquals('00123', DataValidator::getZeroPaddedValue('0000123', 5), "getZeroPaddedValue does not properly unpad and re-pad a value when leading zeroes exist in the initial value");
     //make sure it fails gracefully when asked to do something silly.
     $this->assertFalse(DataValidator::getZeroPaddedValue('123456', 5), "getZeroPaddedValue does not return false when the exact desired value is impossible");
 }
開發者ID:wikimedia,項目名稱:wikimedia-fundraising-crm-vendor,代碼行數:12,代碼來源:DataValidatorTest.php

示例2: stage

 public function stage(GatewayType $adapter, $normalized, &$stagedData)
 {
     // Pad some fields with zeros, to their maximum length.
     $fields = array('account_number', 'bank_code', 'branch_code');
     foreach ($fields as $field) {
         if (isset($normalized[$field])) {
             $constraints = $adapter->getDataConstraints($field);
             if (isset($constraints['length'])) {
                 $newval = DataValidator::getZeroPaddedValue($normalized[$field], $constraints['length']);
                 if ($newval !== false) {
                     $stagedData[$field] = $newval;
                 } else {
                     // Invalid value, so blank the field.
                     $stagedData[$field] = '';
                 }
             }
         }
     }
 }
開發者ID:wikimedia,項目名稱:wikimedia-fundraising-crm-vendor,代碼行數:19,代碼來源:IngenicoFinancialNumber.php


注:本文中的DataValidator::getZeroPaddedValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。