本文整理汇总了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;
}
示例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);
}
示例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);
}
示例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);
}
示例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)));
}
示例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);
}