TQ\Svn\Repository\Repository::open PHP Method

open() public static method

Opens a SVN repository on the file system
public static open ( string $repositoryPath, Binary | string | null $svn = null ) : Repository
$repositoryPath string The full path to the repository
$svn TQ\Svn\Cli\Binary | string | null The SVN binary
return Repository
    public static function open($repositoryPath, $svn = null)
    {
        $svn = Binary::ensure($svn);
        if (!is_string($repositoryPath)) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid path', $repositoryPath));
        }
        $repositoryRoot = self::findRepositoryRoot($svn, $repositoryPath);
        if ($repositoryRoot === null) {
            throw new \InvalidArgumentException(sprintf('"%s" is not a valid SVN repository', $repositoryPath));
        }
        return new static($repositoryRoot, $svn);
    }

Usage Example

 /**
  * Sets up the fixture, for example, open a network connection.
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     Helper::removeDirectory(TESTS_TMP_PATH);
     Helper::createDirectory(TESTS_TMP_PATH);
     $repositories = array(TESTS_REPO_PATH_1, TESTS_REPO_PATH_2, TESTS_REPO_PATH_3);
     foreach ($repositories as $n => $repository) {
         Helper::createDirectory($repository);
         Helper::initEmptySvnRepository($repository);
         for ($i = 0; $i < 5; $i++) {
             $file = sprintf('file_%d.txt', $i);
             $path = $repository . '/' . $file;
             file_put_contents($path, sprintf('Repository %d - File %d', $n + 1, $i + 1));
             Helper::executeSvn($repository, sprintf('add %s', escapeshellarg($file)));
         }
         Helper::executeSvn($repository, sprintf('commit --message=%s', escapeshellarg('Initial commit')));
     }
     clearstatcache();
     $binary = new Binary(SVN_BINARY);
     StreamWrapper::register('svn', $binary);
     StreamWrapper::getRepositoryRegistry()->addRepositories(array('repo1' => Repository::open(TESTS_REPO_PATH_1, $binary), 'repo2' => Repository::open(TESTS_REPO_PATH_2, $binary)));
 }
All Usage Examples Of TQ\Svn\Repository\Repository::open