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


PHP Assert::alnum方法代码示例

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


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

示例1: register

 /**
  * Registers a repository as PHP stream wrapper.
  *
  * The resources of the repository can subsequently be accessed with PHP's
  * file system by prefixing the resource paths with the registered URI
  * scheme:
  *
  * ```php
  * ResourceStreamWrapper::register('puli', $repo);
  *
  * // /app/css/style.css
  * $contents = file_get_contents('puli:///app/css/style.css');
  * ```
  *
  * Instead of passing a repository, you can also pass a callable. The
  * callable is executed when the repository is accessed for the first time
  * and should return a valid {@link ResourceRepository} instance.
  *
  * @param string                      $scheme            The URI scheme.
  * @param ResourceRepository|callable $repositoryFactory The repository to use.
  *
  * @throws StreamWrapperException If a repository was previously registered
  *                                for the same scheme. Call
  *                                {@link unregister()} to unregister the
  *                                scheme first.
  */
 public static function register($scheme, $repositoryFactory)
 {
     if (!$repositoryFactory instanceof ResourceRepository && !is_callable($repositoryFactory)) {
         throw new InvalidArgumentException(sprintf('The repository factory should be a callable or an instance ' . 'of ResourceRepository. Got: %s', $repositoryFactory));
     }
     Assert::string($scheme, 'The scheme must be a string. Got: %s');
     Assert::alnum($scheme, 'The scheme %s should consist of letters and digits only.');
     Assert::startsWithLetter($scheme, 'The scheme %s should start with a letter.');
     if (isset(self::$repos[$scheme])) {
         throw new StreamWrapperException(sprintf('The scheme "%s" has already been registered.', $scheme));
     }
     self::$repos[$scheme] = $repositoryFactory;
     stream_wrapper_register($scheme, __CLASS__);
 }
开发者ID:SenseException,项目名称:repository,代码行数:40,代码来源:ResourceStreamWrapper.php


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