本文整理汇总了PHP中Folder::inPath方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::inPath方法的具体用法?PHP Folder::inPath怎么用?PHP Folder::inPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Folder
的用法示例。
在下文中一共展示了Folder::inPath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testInPath
/**
* testInPath method
*
* @access public
* @return void
*/
function testInPath()
{
$path = dirname(dirname(__FILE__));
$inside = dirname($path) . DS;
$Folder = new Folder($path);
$result = $Folder->pwd();
$this->assertEqual($result, $path);
$result = Folder::isSlashTerm($inside);
$this->assertTrue($result);
$result = $Folder->realpath('tests/');
$this->assertEqual($result, $path . DS . 'tests' . DS);
$result = $Folder->inPath('tests' . DS);
$this->assertTrue($result);
$result = $Folder->inPath(DS . 'non-existing' . $inside);
$this->assertFalse($result);
}
示例2: testInPath
/**
* testInPath method
*
* @return void
*/
public function testInPath()
{
$path = dirname(dirname(__FILE__));
$inside = dirname($path) . DS;
$Folder = new Folder($path);
$result = $Folder->pwd();
$this->assertEquals($path, $result);
$result = Folder::isSlashTerm($inside);
$this->assertTrue($result);
$result = $Folder->realpath('Test/');
$this->assertEquals($path . DS . 'Test' . DS, $result);
$result = $Folder->inPath('Test' . DS);
$this->assertTrue($result);
$result = $Folder->inPath(DS . 'non-existing' . $inside);
$this->assertFalse($result);
$result = $Folder->inPath($path . DS . 'Model', true);
$this->assertTrue($result);
}
示例3: location
/**
* Checks if path is within given locations
*
* @param string $check Absolute path
* @param mixed $allow True or * allows any location,
* an array containing absolute paths to locations
* @return boolean
*/
function location($check, $allow = false)
{
$allow = self::_normalize($allow);
if ($allow === true) {
return true;
} elseif ($allow === false) {
return false;
}
if (!is_array($allow)) {
$allow = array($allow);
} else {
$allow = array_unique($allow);
}
if (Validation::url($check)) {
foreach ($allow as $path) {
if (preg_match('/^' . preg_quote($path, '/') . '/', $check)) {
return true;
}
}
} elseif (MediaValidation::file($check, false)) {
$check = dirname($check);
if (!Folder::isAbsolute($check)) {
return false;
}
$Check = new Folder($check);
foreach ($allow as $path) {
if (!Folder::isAbsolute($path) || Validation::url($path)) {
continue;
}
if ($Check->inPath($path)) {
return true;
}
}
}
return false;
}
示例4: testInPathInvalidPathArgument
/**
* @dataProvider inPathInvalidPathArgumentDataProvider
* @param string $path
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The $path argument is expected to be an absolute path.
*/
public function testInPathInvalidPathArgument($path)
{
$Folder = new Folder();
$Folder->inPath($path);
}