/** * @param $path * @param bool $withRoot * @param bool $withPath * @return mixed */ protected function normalizePath($path, $withRoot = false, $withPath = true) { $path = ($withRoot ? $this->root : null) . FileUtils::normalizePath(($withPath ? $this->path . '/' : '') . '/' . $path); return $path; }
/** * @param $path * @param bool $withRoot Set to true to prepend project root to the normalized path * @param $withBasePath * @return string */ public function normalizePath($path, $withRoot = false, $withBasePath = true) { $dir = null; if (!FileUtils::isAbsolute($path)) { $dir = ($withRoot ? $this->projectRoot . '/' : null) . ($withBasePath ? $this->savePath . '/' : null); } return FileUtils::normalizePath($dir . $path); }
/** * @param string $oldName * @param array $transform * @return string */ protected function generateModifiedSaveName($oldName, $transform) { $name = $this->getTransformer()->generateName($transform); // Extract information from original file $directory = dirname($oldName); $originalName = pathinfo($oldName, PATHINFO_FILENAME); $extension = pathinfo($oldName, PATHINFO_EXTENSION); return FileUtils::normalizePath(sprintf('%s/%s-%s.%s', $directory, $originalName, $name, $extension)); }
/** * Creates an SQLiteConnection * * @param array $parameters Connection parameters * <pre> * database: eg my_app.db * </pre> * * @return \PDO */ public function createConnection($parameters) { $path = FileUtils::normalizePath($parameters['database']); $connection = new \PDO('sqlite:' . $path); return $connection; }
public function testVerifyPathExists() { $storage = $this->createStorage($this->createBaseUrlImpl()); $path = FileUtils::normalizePath(__DIR__ . '/../../files/photo'); $this->assertEquals($path, $storage->verifyPathExists($path)); $this->setExpectedException('RuntimeException'); $storage->verifyPathExists('test/directory', false); }