4 * This file is part of the Behat Gherkin.
5 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
11 namespace Behat\Gherkin\Loader;
14 * Abstract filesystem loader.
16 * @author Konstantin Kudryashov <ever.zet@gmail.com>
18 abstract class AbstractFileLoader implements FileLoaderInterface
23 * Sets base features path.
25 * @param string $path Base loader path
27 public function setBasePath($path)
29 $this->basePath = realpath($path);
33 * Finds relative path for provided absolute (relative to base features path).
35 * @param string $path Absolute path
39 protected function findRelativePath($path)
41 if (null !== $this->basePath) {
42 return strtr($path, array($this->basePath . DIRECTORY_SEPARATOR => ''));
49 * Finds absolute path for provided relative (relative to base features path).
51 * @param string $path Relative path
55 protected function findAbsolutePath($path)
57 if (is_file($path) || is_dir($path)) {
58 return realpath($path);
61 if (null === $this->basePath) {
65 if (is_file($this->basePath . DIRECTORY_SEPARATOR . $path)
66 || is_dir($this->basePath . DIRECTORY_SEPARATOR . $path)) {
67 return realpath($this->basePath . DIRECTORY_SEPARATOR . $path);