本文整理汇总了PHP中Path::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Path::factory方法的具体用法?PHP Path::factory怎么用?PHP Path::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Path
的用法示例。
在下文中一共展示了Path::factory方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testWithRegisteredNamespaces
public function testWithRegisteredNamespaces()
{
$map = new Maps\Rss();
$result = $map->execute($this->object);
$map->add(Path::factory('/rss/channel/feedburner:feedFlare', 'feedFlare')->loop(true));
$this->assertTrue(is_array($result));
$this->assertFalse(array_key_exists('feedFlare', $result));
$map->registerNamespace('feedburner', "http://rssnamespace.org/feedburner/ext/1.0");
$result2 = $map->execute($this->object);
$this->assertArrayHasKey('feedFlare', $result2);
}
示例2: testFilteredValue
public function testFilteredValue()
{
$map = new Map();
$map->add(Path::factory('/test/description', 'desc')->setDefault('value')->filter(function ($val) {
return strrev($val);
}));
$result = $map->execute($this->object);
$this->assertTrue(is_array($result));
$this->assertArrayHasKey('desc', $result);
$this->assertEquals(strrev("test description"), $result['desc']);
}
示例3: testWrongPath
public function testWrongPath()
{
$map = new Map();
$map->add(Path::factory('/test', 'test')->addChildren(Path::factory('wrong>path', 'wrong', 'defaultFalse')));
$result = $map->execute(new XmlFile(__DIR__ . '/test.xml'));
$this->assertTrue(is_array($result));
$this->assertArrayHasKey('test', $result);
$this->assertTrue(is_array($result['test']));
$this->assertArrayHasKey('wrong', $result['test']);
$this->assertEquals('defaultFalse', $result['test']['wrong']);
}