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


PHP Preconditions::checkMatchesPattern方法代碼示例

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


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

示例1: invokeAction

 /**
  * Invoke an action given its name
  *
  * This function checks if public non-abstract non-static runAction method
  * exists in this object and calls it in such a case with request and response
  * parameters
  *
  * @param Trace $trace trace object
  * @param string $action action name
  * @param Context $context fajr context
  */
 public function invokeAction(Trace $trace, $action, Context $context)
 {
     Preconditions::checkIsString($action);
     Preconditions::checkMatchesPattern('@^[A-Z][a-zA-Z]*$@', $action, '$action must start with capital letter and ' . 'contain only letters.');
     $methodName = 'run' . $action;
     if (!method_exists($this, $methodName)) {
         throw new Exception('Action method ' . $methodName . ' does not exist');
     }
     $method = new ReflectionMethod($this, $methodName);
     if (!$method->isPublic()) {
         throw new Exception('Action method ' . $methodName . ' is not public');
     }
     if ($method->isAbstract()) {
         throw new Exception('Action method ' . $methodName . ' is abstract');
     }
     if ($method->isStatic()) {
         throw new Exception('Action method ' . $methodName . ' is static');
     }
     if ($method->isConstructor()) {
         throw new Exception('Action method ' . $methodName . ' is constructor');
     }
     if ($method->isDestructor()) {
         throw new Exception('Action method ' . $methodName . ' is destructor');
     }
     $method->invoke($this, $trace, $context);
 }
開發者ID:BGCX067,項目名稱:fajr-svn-to-git,代碼行數:37,代碼來源:BaseController.php

示例2: initialize

 /**
  * Initialize this storage instance.
  *
  * Available options:
  *  * table_name: string
  *  * key_col: string column of the keys
  *  * data_col: string column of the data
  *  * additional_indexes: array(col=>value) list of additional indexes to use
  * Warning: NEVER use column names supplied by user. This class have some
  * safety measures against this type of injection, but it is not bulletproof.
  *
  * @param array $options An associative array of options
  *
  * @returns bool true, if initialization completes successfully
  */
 public function initialize($options = array())
 {
     parent::initialize($options);
     // $options are now available as $this->options
     $needed_options = array('table_name', 'key_col', 'data_col');
     foreach ($needed_options as $needed) {
         if (!isset($this->options[$needed])) {
             throw new sfInitializationException('You must provide a "' . $needed . '" option to DatabaseStorage.');
         }
     }
     // check required options
     Preconditions::checkIsString($this->options['table_name']);
     Preconditions::checkMatchesPattern(self::SAFE_TABLE_NAME, $this->options['table_name']);
     Preconditions::checkIsString($this->options['key_col']);
     Preconditions::checkMatchesPattern(self::SAFE_COLUMN_NAME, $this->options['key_col']);
     Preconditions::checkIsString($this->options['data_col']);
     Preconditions::checkMatchesPattern(self::SAFE_COLUMN_NAME, $this->options['data_col']);
     // check optional options
     if (isset($options['additional_indexes'])) {
         foreach ($options['additional_indexes'] as $name => $value) {
             Preconditions::checkIsString($name);
             Preconditions::checkMatchesPattern(self::SAFE_COLUMN_NAME, $name);
         }
     }
 }
開發者ID:BGCX067,項目名稱:fajr-svn-to-git,代碼行數:40,代碼來源:DatabaseStorage.php

示例3: __construct

 /**
  * Construct a CosignServiceCookie if all arguments are valid
  *
  * @param string $name   Cookie name
  * @param string $value  Cookie value
  * @param string $domain Cookie domain
  */
 public function __construct($name, $value, $domain)
 {
     Preconditions::checkMatchesPattern(self::NAME_PATTERN, $name, '$name did not match allowed pattern.');
     Preconditions::checkMatchesPattern(self::VALUE_PATTERN, $value, '$value did not match allowed pattern.');
     Preconditions::checkMatchesPattern(self::DOMAIN_PATTERN, $domain, '$domain did not match allowed pattern.');
     $this->name = $name;
     $this->value = $value;
     $this->domain = $domain;
 }
開發者ID:BGCX067,項目名稱:fajr-svn-to-git,代碼行數:16,代碼來源:CosignServiceCookie.php

示例4: read

 /**
  * Reads data from this storage.
  * Reading non-existent key will return null.
  *
  * @param string $key key to the data
  *
  * @returns mixed Data associated with the key
  *
  * @throws sfStorageException on failure
  */
 public function read($key)
 {
     Preconditions::checkIsString($key);
     // basic sanity checking so there will be no binary-data tricks
     Preconditions::checkMatchesPattern('@^[a-zA-Z0-9._/]*$@', $key, 'Key contains invalid characters');
     $path = $this->options['root_path'] . '/' . $key . '.dat';
     if (!file_exists($path)) {
         return null;
         // empty read
     }
     $content = file_get_contents($path);
     if ($content === false) {
         throw new sfStorageException("Failed to read data for key '{$key}'");
     }
     $value = @eval($content);
     if ($value === false) {
         throw new sfStorageException("Parse error while reading data for key '{$key}'");
     }
     if ($value === null) {
         throw new sfStorageException("No returned value while reading data for key '{$key}'");
     }
     return $value;
 }
開發者ID:BGCX067,項目名稱:fajr-svn-to-git,代碼行數:33,代碼來源:FileStorage.php

示例5: testIsStringAndMatchesFailOnNonMatch

 public function testIsStringAndMatchesFailOnNonMatch()
 {
     $this->setExpectedException("InvalidArgumentException");
     $x = 'def';
     Preconditions::checkMatchesPattern("/^abc\$/", $x, "not matching");
 }
開發者ID:BGCX067,項目名稱:fajr-svn-to-git,代碼行數:6,代碼來源:PreconditionsTest.php


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