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


PHP Assert::allString方法代码示例

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


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

示例1: __construct

 /**
  * Creates a new command name.
  *
  * @param string   $string  The command name.
  * @param string[] $aliases The alias names.
  */
 public function __construct($string, array $aliases = array())
 {
     Assert::string($string, 'The command name must be a string. Got: %s');
     Assert::notEmpty($string, 'The command name must not be empty.');
     Assert::regex($string, '~^[a-zA-Z0-9\\-]+$~', 'The command name must contain letters, digits and hyphens only. Got: "%s"');
     Assert::allString($aliases, 'The command aliases must be strings. Got: %s');
     Assert::allNotEmpty($aliases, 'The command aliases must not be empty.');
     Assert::allRegex($aliases, '~^[a-zA-Z0-9\\-]+$~', 'The command aliases must contain letters, digits and hyphens only. Got: "%s"');
     $this->string = $string;
     $this->aliases = $aliases;
 }
开发者ID:webmozart,项目名称:console,代码行数:17,代码来源:CommandName.php

示例2: join

 /**
  * Joins two or more path strings.
  *
  * The result is a canonical path.
  *
  * @param string[]|string $paths Path parts as parameters or array.
  *
  * @return string The joint path.
  *
  * @since 2.0 Added method.
  */
 public static function join($paths)
 {
     if (!is_array($paths)) {
         $paths = func_get_args();
     }
     Assert::allString($paths, 'The paths must be strings. Got: %s');
     $finalPath = null;
     $wasScheme = false;
     foreach ($paths as $path) {
         $path = (string) $path;
         if ('' === $path) {
             continue;
         }
         if (null === $finalPath) {
             // For first part we keep slashes, like '/top', 'C:\' or 'phar://'
             $finalPath = $path;
             $wasScheme = strpos($path, '://') !== false;
             continue;
         }
         // Only add slash if previous part didn't end with '/' or '\'
         if (!in_array(substr($finalPath, -1), array('/', '\\'))) {
             $finalPath .= '/';
         }
         // If first part included a scheme like 'phar://' we allow current part to start with '/', otherwise trim
         $finalPath .= $wasScheme ? $path : ltrim($path, '/');
         $wasScheme = false;
     }
     if (null === $finalPath) {
         return '';
     }
     return self::canonicalize($finalPath);
 }
开发者ID:akochnov,项目名称:fts,代码行数:43,代码来源:Path.php


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