当前位置: 首页>>代码示例>>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;未经允许,请勿转载。