X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/ede9ef521fbe3b9fc3ee95c410edd906f8e64284..48c36233ec93e9a236c503628dee064c4366eee9:/src/phorkie/Repositories.php diff --git a/src/phorkie/Repositories.php b/src/phorkie/Repositories.php index 7ed3188..4a91e96 100644 --- a/src/phorkie/Repositories.php +++ b/src/phorkie/Repositories.php @@ -9,21 +9,20 @@ class Repositories $this->gitDir = $GLOBALS['phorkie']['cfg']['gitdir']; } - /** - * @return Repository - */ - public function createNew() + public function createNew(): Repository { chdir($this->gitDir); $dirs = glob('*.git', GLOB_ONLYDIR); - array_walk( - $dirs, - function ($dir) { - return substr($dir, 0, -4); - } - ); + foreach ($dirs as $key => $dir) { + $dirs[$key] = substr($dir, 0, -4); + } sort($dirs, SORT_NUMERIC); - $n = end($dirs) + mt_rand(65536, 16777216); + + if ($GLOBALS['phorkie']['cfg']['randomIds']) { + $n = end($dirs) + mt_rand(65536, 16777216); + } else { + $n = end($dirs) + 1; + } chdir($this->workDir); $dir = $this->workDir . '/' . $n . '/'; @@ -45,7 +44,7 @@ class Repositories * * @return array Array of Repositories first, number of repositories second */ - public function getList($page = 0, $perPage = 10) + public function getList($page = 0, $perPage = 10): array { chdir($this->gitDir); $dirs = glob('*.git', GLOB_ONLYDIR);