function __construct($name) { if (!Filename::isValid($name)) { throw new NameException($name); } $this->name = $name; }
function __construct($name, $content = '') { if (!Filename::isValid($name)) { throw new NameException($name); } $this->name = $name; $this->setContent($content); }
function __construct($name, $rootDir) { if (!Filename::isValid($name)) { throw new NameException(); } $this->name = $name; $rootDir = realpath($rootDir); if ($rootDir !== false && is_dir($rootDir)) { $this->rootDir = $rootDir; } else { throw new FolderNotFoundException($rootDir); } }
function __construct($name, $host, $username, $password) { if (!Filename::isValid($name) || $host === '') { throw new NameException(); } if ($username === '') { $username = '******'; } if ($password === '') { $password = '******'; } $this->name = $name; $this->host = $host; $this->username = $username; $this->password = $password; $this->getConnection(); }
function rename($path, $newName) { if (!Filename::isValid($newName)) { throw new NameException(); } $splitPaths = Path::split($path); if (!$splitPaths) { throw new NameException(); } $passedFolders = []; $parent = $this->rootFolder; if ($parent->isProxy) { $parent->rename(Path::join($splitPaths), $newName); return; } while (count($splitPaths) > 1) { $folderName = array_shift($splitPaths); $passedFolders[] = $folderName; $item = $parent->get($folderName); if (!$item) { throw new FolderNotFoundException(Path::join($passedFolders)); } else { if ($item instanceof File) { $passedFolders[] = array_shift($splitPaths); throw new FolderNotFoundException(Path::join($passedFolders)); } elseif ($item->isProxy) { $item->rename(Path::join($splitPaths), $newName); return; } } $parent = $item; } $item = $splitPaths[0]; $parent->rename($item, $newName); }