/** * Renames a file/directory and returns a new file/directory * Also moves the file/directory if necessary * @param string $newPath * @param bool|false $overwrite * @return bool * @throws MoveException * @throws OverwriteException */ public function rename($newPath, $overwrite = false) { if (!$overwrite && FileSystemHelper::doesExist($newPath)) { throw new OverwriteException($newPath); } $success = rename($this->getPath(), $newPath); if ($success) { $this->filePath = FileSystemHelper::toFullPath($newPath); } else { throw new MoveException($this->getPath(), $newPath); } return $success; }
/** * @covers Corgi\File\Helpers\FileSystemHelper::toFullPath */ public function testToFullPath() { $this->assertInternalType('string', FileSystemHelper::toFullPath('/arbitrary/file/path')); }