本文整理汇总了PHP中Webmozart\PathUtil\Path::hasExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::hasExtension方法的具体用法?PHP Path::hasExtension怎么用?PHP Path::hasExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\PathUtil\Path
的用法示例。
在下文中一共展示了Path::hasExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new runner.
*
* @param string|null $binDir The path to Composer's "bin-dir".
*/
public function __construct($binDir = null)
{
$phpFinder = new PhpExecutableFinder();
if (!($php = $phpFinder->find())) {
throw new RuntimeException('The "php" command could not be found.');
}
$puliFinder = new ExecutableFinder();
// Search:
// 1. in the current working directory
// 2. in Composer's "bin-dir"
// 3. in the system path
$searchPath = array_merge(array(getcwd()), (array) $binDir);
// Search "puli.phar" in the PATH and the current directory
if (!($puli = $puliFinder->find('puli.phar', null, $searchPath))) {
// Search "puli" in the PATH and Composer's "bin-dir"
if (!($puli = $puliFinder->find('puli', null, $searchPath))) {
throw new RuntimeException('The "puli"/"puli.phar" command could not be found.');
}
}
if (Path::hasExtension($puli, '.bat', true)) {
$this->puli = $puli;
} else {
$this->puli = $php . ' ' . $puli;
}
}
示例2: testHasExtensionFailsIfInvalidExtension
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The extensions must be strings. Got: stdClass
*/
public function testHasExtensionFailsIfInvalidExtension()
{
Path::hasExtension('/style.css', (object) array());
}