public function getRootPath()
{
$path = ltrim($this->path, '/');
if (0 === ($nb = substr_count($path, DIRECTORY_SEPARATOR))) {
return '.';
}
return rtrim(str_repeat('../', $nb), '/');
}
/** * @dataProvider getGetRootPathTests */ public function testGetRootPath($expected, $path) { $document = new Document(); $document->setPath($path); $this->assertSame($expected, $document->getRootPath()); }