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


PHP Result::addMessage方法代碼示例

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


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

示例1: isValid

 public function isValid($value)
 {
     $result = new Result(['value' => true]);
     foreach ($this->validators as $validator) {
         if ($result && method_exists($validator, 'getSkipOnPass') && $validator->getSkipOnPass()) {
             continue;
         }
         if (!$result && method_exists($validator, 'getSkipOnFail') && $validator->getSkipOnFail()) {
             continue;
         }
         $validatorResult = $validator->isValid($value);
         if (!$validatorResult->getValue()) {
             $result->setValue(false);
             foreach ($validatorResult->getMessages() as $message) {
                 $result->addMessage($message);
             }
             if (method_exists($validator, 'getHaltOnFail') && $validator->getHaltOnFail()) {
                 return $result;
             }
         }
         if (method_exists($validator, 'getHaltOnPass') && $validator->getHaltOnPass()) {
             return $result;
         }
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:26,代碼來源:Chain.php

示例2: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (is_string($value)) {
         $value = trim($value);
     }
     if (!isset($value) || $value === null || $value === '') {
         $result->setValue(false);
         $result->addMessage('required');
     }
     if (is_array($value) && count($value) == 0) {
         $result->setValue(false);
         $result->addMessage('required');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:16,代碼來源:Required.php

示例3: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!$this->length->isValid($value)->getValue()) {
         $result->setValue(false);
         $result->addMessage('passwordLength');
     }
     if (!preg_match($this->containAlphaRegEx, $value)) {
         $result->setValue(false);
         $result->addMessage('passwordAlpha');
     }
     if (!preg_match($this->containNumRegEx, $value)) {
         $result->setValue(false);
         $result->addMessage('passwordNum');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:17,代碼來源:Password.php

示例4: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!preg_match($this->regex, $value)) {
         $result->setValue(false);
         $result->addMessage('alpha');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Email.php

示例5: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!$value instanceof \DateTime) {
         $result->setValue(false);
         $result->addMessage('date');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Date.php

示例6: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!preg_match('/^\\d{1,2}$/', $value['month']) || !preg_match('/^\\d\\d\\d\\d$/', $value['year'])) {
         $result->setValue(false);
         $result->addMessage('creditCardExpiry');
         return $result;
     }
     $month = (int) $value['month'];
     $year = (int) $value['year'];
     $compareYear = date('Y');
     $compareMonth = date('n');
     if ($month < 1 || $month > 12 || $year < $compareYear || $year == $compareYear && $month < $compareMonth) {
         $result->setValue(false);
         $result->addMessage('creditCardExpiry');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:18,代碼來源:CreditCardExpiry.php

示例7: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!($value < $this->compare)) {
         $result->setValue(false);
         $result->addMessage('lessThan');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:LessThan.php

示例8: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!($value === $this->compare && !$value instanceof \DateTime) && !($value instanceof \DateTime && $this->compare instanceof \DateTime && $value == $this->compare)) {
         $result->setValue(false);
         $result->addMessage('equal');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Equal.php

示例9: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!is_numeric($value)) {
         $result->setValue(false);
         $result->addMessage('float');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Float.php

示例10: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if ($value !== true && $value !== false) {
         $result->setValue(false);
         $result->addMessage('boolean');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Boolean.php

示例11: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!is_string($value)) {
         $result->setValue(false);
         $result->addMessage('string');
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:String.php

示例12: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     if (!preg_match('/' . $this->regex . '/', $value)) {
         $result->setValue(false);
         $result->addMessage(['regex', $this->regex]);
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:9,代碼來源:Regex.php

示例13: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     $length = strlen($value);
     if ($length < $this->min || $length > $this->max) {
         $result->setValue(false);
         $result->addMessage(['length', $this->min, $this->max]);
     }
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:10,代碼來源:Length.php

示例14: isValid

 public function isValid($value)
 {
     $result = new Result(["value" => true]);
     $value = preg_replace('/[- ]/', '', $value);
     foreach ($this->cardInfo as $regex) {
         if (preg_match('/^' . $regex . '$/', $value)) {
             return $result;
         }
     }
     $result->setValue(false);
     $result->addMessage('creditCard');
     return $result;
 }
開發者ID:zoopcommerce,項目名稱:mystique-php,代碼行數:13,代碼來源:CreditCard.php

示例15: run

 /**
  * PHPca's main method. Returns a result object holding
  * error and warning messages for all the files that have been analyzed.
  *
  * @param string $pathToPhpExecutable path to PHP executable for lint check
  * @param string $fileOrDirectory     path to file or directory to check
  * @return object
  */
 public function run($pathToPhpExecutable, $fileOrDirectory, Configuration $configuration = null)
 {
     if ($pathToPhpExecutable == '') {
         throw new Exception('No path to PHP executable specified');
     }
     if ($fileOrDirectory == '') {
         throw new Exception('No file or directory to analyze');
     }
     if (!is_null($configuration)) {
         $this->configuration = $configuration;
     }
     // Define our own additionl T_* token constants
     Constants::init();
     // Set up the lint checker and make sure that given path points to a PHP binary
     $linter = new Linter($pathToPhpExecutable);
     // Create result object that collects the error and warning messages
     $this->result = new Result();
     // Create a list of all rules to enforce
     $this->rules = $this->loadRules($this->configuration->getRules());
     // List all PHP files in given path
     $phpFiles = $this->listFiles($fileOrDirectory, $this->configuration->getExtensions());
     if (sizeof($phpFiles) == 0) {
         throw new Exception('No PHP files to analyze');
     }
     $this->numberOfFiles = sizeof($phpFiles);
     foreach ($phpFiles as $phpFile) {
         // Remember that we have processed this file,
         // even if it generates no message at all.
         $this->result->addFile($phpFile);
         if ($this->isSkipped($phpFile)) {
             $this->result->addMessage(new Skipped($phpFile, 'Skipped'));
         } else {
             if ($linter->runLintCheck($phpFile)) {
                 $file = Tokenizer::tokenize($phpFile, file_get_contents($phpFile));
                 $this->result->addNamespaces($phpFile, $file->getNamespaces());
                 $this->result->addClasses($phpFile, $file->getClasses());
                 $this->result->addFunctions($phpFile, $file->getFunctions());
                 $this->enforceRules($phpFile, $file);
             } else {
                 $this->result->addMessage(new LintError($phpFile, $linter->getErrorMessages()));
             }
         }
         // Notify the progress printer that we have analyzed a file
         if (is_object($this->progressPrinter)) {
             $this->progressPrinter->showProgress($phpFile, $this->result, $this);
         }
         unset($phpFile);
     }
     // Return the result object containing all error and warning messages
     return $this->result;
 }
開發者ID:ncud,項目名稱:sagalaya,代碼行數:59,代碼來源:Application.php


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