/** * Loads the configuration file and returns it. * * @param string $file The configuration file path. * * @return Configuration The configuration settings. */ public function loadFile($file = null) { if (null === $file) { $file = $this->getDefaultPath(); } $json = $this->json->decodeFile($file); if (isset($json->import)) { if (!Path::isAbsolute($json->import)) { $json->import = Path::join(array(dirname($file), $json->import)); } $json = (object) array_merge((array) $this->json->decodeFile($json->import), (array) $json); } $this->json->validate($this->json->decodeFile(CRATE_SCHEMA_FILE), $json); return new Configuration($file, $json); }
/** * Returns the output file path. * * @return string The file path. */ public function getOutputPath() { $base = getcwd() . DIRECTORY_SEPARATOR; if (isset($this->raw->output)) { $path = $this->raw->output; if (false === Path::isAbsolute($path)) { $path = Path::canonical($base . $path); } } else { $path = $base . 'default.phar'; } if (false !== strpos($path, '@' . 'git-version@')) { $path = str_replace('@' . 'git-version@', $this->getGitVersion(), $path); } return $path; }
/** * Performs a battery of tests against the `Path::isAbsolute()` method * using the `getAbsolutePaths()` data provider. Any edge cases found * should be submitted as patch that will add a new entry to the data * provider. * * @dataProvider getAbsolutePaths * * @param string $input The input path. * @param string $result The expected result. */ public function testIsAbsolute($input, $result) { $this->assertSame($result, Path::isAbsolute($input)); }