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


PHP Assert::isString方法代码示例

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


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

示例1: __construct

 public function __construct($root, $path)
 {
     Assert::isString($path, 'non-string path given');
     if (is_object($root)) {
         $className = get_class($root);
     } else {
         Assert::classExists($root);
         $className = $root;
     }
     $this->root = $className;
     $this->path = $path;
     $this->fetchHelpers($className);
     $proto = self::$protos[$className];
     $path = explode('.', $path);
     for ($i = 0, $size = count($path); $i < $size; ++$i) {
         $this->properties[$i] = $property = $proto->getPropertyByName($path[$i]);
         if ($className = $property->getClassName()) {
             $this->fetchHelpers($className);
             $proto = self::$protos[$className];
         } elseif ($i < $size) {
             continue;
         } else {
             throw new WrongArgumentException('corrupted path');
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:26,代码来源:PropertyPath.class.php

示例2: setAllowableTags

 /**
  * @return StripTagsFilter
  **/
 public function setAllowableTags($exclude)
 {
     if (null !== $exclude) {
         Assert::isString($exclude);
     }
     $this->exclude = $exclude;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:11,代码来源:StripTagsFilter.class.php

示例3: makeFullTextQuery

 /**
  * @throws WrongArgumentException
  * @return SelectQuery
  **/
 public static function makeFullTextQuery(FullTextDAO $dao, Criteria $criteria, $string)
 {
     Assert::isString($string, 'only strings accepted today');
     $array = self::prepareSearchString($string);
     if (!$array) {
         throw new ObjectNotFoundException();
     }
     if (!($field = $dao->getIndexField()) instanceof DBField) {
         $field = new DBField($dao->getIndexField(), $dao->getTable());
     }
     return $criteria->toSelectQuery()->andWhere(Expression::fullTextOr($field, $array))->prependOrderBy(Expression::fullTextRankAnd($field, $array))->desc();
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:16,代码来源:FullTextUtils.class.php

示例4: isFloat

 /**
  * isFloat
  * @param mixed $value
  * @return float
  */
 public static function isFloat($value)
 {
     if (is_object($value)) {
         $value = Assert::isString($value);
     }
     if (is_float($value)) {
         return $value;
     } elseif (is_int($value)) {
         return (double) $value;
     } elseif (is_scalar($value) && (preg_match('@^-?[0-9]+(\\.[0-9]+)?$@', $value) || trim($value) == '')) {
         return (double) $value;
     } else {
         throw new \InvalidArgumentException('Must be Float: ' . print_r($value, true));
     }
 }
开发者ID:bullhorn,项目名称:fast-rest,代码行数:20,代码来源:Assert.php

示例5: parse

 /**
  * @return OqlQueryClause
  **/
 public function parse($string = null)
 {
     if ($string === null) {
         Assert::isNotNull($this->tokenizer);
     } else {
         Assert::isString($string);
         $this->tokenizer = new OqlTokenizer($string);
     }
     $this->state = self::INITIAL_STATE;
     $this->oqlObject = $this->makeOqlObject();
     $this->parentheses = 0;
     while ($this->state != self::FINAL_STATE) {
         $this->state = $this->handleState();
     }
     $this->checkParentheses();
     return $this->oqlObject;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:20,代码来源:OqlParser.class.php

示例6: __construct

 public function __construct()
 {
     $args = func_get_args();
     if (count($args) == 1 && is_array($args[0])) {
         $args = $args[0];
     }
     if (count($args) == 2) {
         //aka start and end
         $this->setup($args[0], $args[1]);
     } elseif (count($args) == 1) {
         //start-end or ip/mask
         Assert::isString($args[0]);
         $this->createFromString($args[0]);
     } else {
         throw new WrongArgumentException('strange parameters received');
     }
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:17,代码来源:IpRange.class.php

示例7: __construct

 public function __construct($input)
 {
     if (Assert::checkInteger($input)) {
         $time = $input;
     } else {
         Assert::isString($input);
         $time = explode(':', $input);
     }
     $lenght = strlen($input);
     if (count($time) === 2) {
         $this->setHour($time[0])->setMinute($time[1]);
     } elseif (count($time) === 3) {
         $this->setHour($time[0])->setMinute($time[1])->setSecond($time[2]);
     } else {
         switch ($lenght) {
             case 1:
             case 2:
                 $this->setHour(substr($input, 0, 2));
                 break;
             case 3:
                 $assumedHour = substr($input, 0, 2);
                 if ($assumedHour > 23) {
                     $this->setHour(substr($input, 0, 1))->setMinute(substr($input, 1, 2));
                 } else {
                     $this->setHour($assumedHour)->setMinute(substr($input, 2, 1) . '0');
                 }
                 break;
             case 4:
             case 5:
             case 6:
                 $this->setHour(substr($input, 0, 2))->setMinute(substr($input, 2, 2))->setSecond(substr($input, 4, 2));
                 break;
             default:
                 throw new WrongArgumentException('unknown format');
         }
     }
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:37,代码来源:Time.class.php

示例8: addAllowedMimeType

 /**
  * @throws WrongArgumentException
  * @return PrimitiveFile
  **/
 public function addAllowedMimeType($mime)
 {
     Assert::isString($mime);
     $this->allowedMimeTypes[] = $mime;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:PrimitiveFile.class.php

示例9: setString

 /**
  * @param $value
  * @return SimpleStringableObject
  */
 public function setString($value)
 {
     Assert::isString($value);
     $this->string = $value;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:JsonPViewTest.class.php

示例10: setReverse

 /**
  * @return RouterRegexpRule
  **/
 public function setReverse($reverse)
 {
     Assert::isString($reverse);
     $this->reverse = $reverse;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:RouterRegexpRule.class.php

示例11: addRule

 /**
  * @throws WrongArgumentException
  * @return Form
  **/
 public function addRule($name, LogicalObject $rule)
 {
     Assert::isString($name);
     $this->rules[$name] = $rule;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:10,代码来源:RegulatedForm.class.php

示例12: __construct

 public function __construct($string)
 {
     Assert::isString($string);
     $this->string = $string;
     $this->length = strlen($string);
 }
开发者ID:rero26,项目名称:onphp-framework,代码行数:6,代码来源:StringInputStream.class.php

示例13: setMessage

 /**
  * @return LogRecord
  **/
 public function setMessage($message)
 {
     Assert::isString($message);
     $this->message = $message;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:9,代码来源:LogRecord.class.php

示例14: check

 protected static function check($string)
 {
     Assert::isString($string);
     Assert::isTrue(preg_match('/^[a-z0-9]+$/iu', $string) !== 0, 'Wrong pattern matching');
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:5,代码来源:Base62Utils.class.php

示例15: setDomain

 public function setDomain($domain)
 {
     Assert::isString($domain);
     $this->domain = $domain;
     return $this;
 }
开发者ID:onphp-framework,项目名称:onphp-framework,代码行数:6,代码来源:Cookie.class.php


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