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


PHP Assert::startsWith方法代码示例

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


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

示例1: resolvePath

 /**
  * Return the path with the basePath prefix
  * if it has been set.
  *
  * @param string $path
  *
  * @return string
  */
 protected function resolvePath($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     if ($this->basePath) {
         $path = $this->basePath . $path;
     }
     $path = Path::canonicalize($path);
     return $path;
 }
开发者ID:frogriotcom,项目名称:Resource,代码行数:18,代码来源:AbstractPhpcrRepository.php

示例2: splitPath

 /**
  * Splits a path into mount point and path.
  *
  * @param string $path The path to split.
  *
  * @return array An array with the mount point and the path. If no mount
  *               point was found, both are `null`.
  */
 private function splitPath($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     $path = Path::canonicalize($path);
     foreach ($this->repos as $mountPoint => $_) {
         if (Path::isBasePath($mountPoint, $path)) {
             // Special case "/": return the complete path
             if ('/' === $mountPoint) {
                 return array($mountPoint, $path);
             }
             return array($mountPoint, substr($path, strlen($mountPoint)));
         }
     }
     return array(null, null);
 }
开发者ID:SenseException,项目名称:repository,代码行数:24,代码来源:CompositeRepository.php

示例3: sanitizePath

 /**
  * Sanitize a given path and check its validity.
  *
  * @param string $path
  *
  * @return string
  */
 protected function sanitizePath($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     return Path::canonicalize($path);
 }
开发者ID:puli,项目名称:repository,代码行数:13,代码来源:AbstractRepository.php

示例4: getGlobIterator

 private function getGlobIterator($query, $language)
 {
     $this->failUnlessGlob($language);
     Assert::stringNotEmpty($query, 'The glob must be a non-empty string. Got: %s');
     Assert::startsWith($query, '/', 'The glob %s is not absolute.');
     $query = Path::canonicalize($query);
     return new GlobIterator($this->baseDir . $query);
 }
开发者ID:puli,项目名称:repository,代码行数:8,代码来源:FilesystemRepository.php

示例5: add

 /**
  * {@inheritdoc}
  */
 public function add($path, $resource)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     $path = Path::canonicalize($path);
     if ($resource instanceof ResourceCollection) {
         $this->ensureDirectoryExists($path);
         foreach ($resource as $child) {
             $this->addResource($path . '/' . $child->getName(), $child);
         }
         // Keep the resources sorted by file name
         ksort($this->resources);
         return;
     }
     if ($resource instanceof Resource) {
         $this->ensureDirectoryExists(Path::getDirectory($path));
         $this->addResource($path, $resource);
         ksort($this->resources);
         return;
     }
     throw new UnsupportedResourceException(sprintf('The passed resource must be a Resource or ResourceCollection. Got: %s', is_object($resource) ? get_class($resource) : gettype($resource)));
 }
开发者ID:SenseException,项目名称:repository,代码行数:25,代码来源:InMemoryRepository.php

示例6: getGlobIterator

 private function getGlobIterator($query, $language)
 {
     if ('glob' !== $language) {
         throw UnsupportedLanguageException::forLanguage($language);
     }
     Assert::stringNotEmpty($query, 'The glob must be a non-empty string. Got: %s');
     Assert::startsWith($query, '/', 'The glob %s is not absolute.');
     $query = Path::canonicalize($query);
     return new GlobIterator($this->baseDir . $query);
 }
开发者ID:SenseException,项目名称:repository,代码行数:10,代码来源:FilesystemRepository.php


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