public function testPathResolver() { $fs = new Filesystem(); $root = $this->_root . '/'; $virtPath = new Path(); $virtPath->set('default', $root); runBench(array('new path (new obj and dir)' => function () use($fs, $root) { $newDir = $root . mt_rand(); $fs->mkdir($newDir); // start $virtPath = new Path(); $virtPath->set('default', $newDir); $result = $virtPath->get('default:'); // end return $result; }, 'same path (new)' => function () use($fs, $root) { $virtPath = new Path(); $virtPath->set('default', $root); $result = $virtPath->get('default:'); return $result; }, 'same path' => function () use($fs, $root, $virtPath) { $result = $virtPath->get('default:'); return $result; }), array('count' => 1000, 'name' => 'path resolver')); }
/** * @param string $module * @param string $format * @return Data */ protected function _listFactory($module, $format) { $key = $module . '.' . $format; if ($list = $this->_storage->get($key)) { return $list; } if ($module === self::DEFAULT_MODULE) { $path = $module . ':langs/' . $this->_code . '.' . $format; } else { $path = $module . ':langs/' . $this->_code . '.' . $module . '.' . $format; } $listPath = $this->_path->get($path); // @codeCoverageIgnoreStart if ('php' === $format) { $list = new PHPArray($listPath); } elseif ('json' === $format) { $list = new JSON($listPath); } elseif ('ini' === $format) { $list = new Ini($listPath); } elseif ('yml' === $format) { $list = new Yml($listPath); } else { $list = new Data([]); } // @codeCoverageIgnoreEnd $this->_storage->set($key, $list); return $list; }
public function testRootPreDefinedAlias() { $path = new Path(__DIR__); $curFile = basename(__FILE__); $this->_is(__FILE__, $path->get('root:' . $curFile)); }