Split complex if statements

This commit is contained in:
Alexander A. Klimov 2015-09-23 15:53:10 +02:00
parent abcdc5adb1
commit d6cf6313b9
1 changed files with 14 additions and 7 deletions

View File

@ -15,14 +15,21 @@ class Version
*/
public static function get()
{
if (false !== ($gitHead = @file_get_contents((
$gitDir = Icinga::app()->getBaseDir('.git')
) . DIRECTORY_SEPARATOR . 'HEAD'))) {
$gitDir = Icinga::app()->getBaseDir('.git');
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . 'HEAD');
if (false !== $gitHead) {
$matches = array();
if ((1 !== @preg_match('/(?<!.)ref:\s+(?P<gitCommitID>.+?)$/ms', $gitHead, $matches) || false !== (
$gitHead = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches['gitCommitID'])
)) && 1 === @preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitHead, $matches)) {
return $matches;
if (@preg_match('/(?<!.)ref:\s+(.+?)$/ms', $gitHead, $matches)) {
$gitCommitID = @file_get_contents($gitDir . DIRECTORY_SEPARATOR . $matches[1]);
} else {
$gitCommitID = $gitHead;
}
if (false !== $gitCommitID) {
$matches = array();
if (@preg_match('/(?<!.)(?P<gitCommitID>[0-9a-f]+)$/ms', $gitCommitID, $matches)) {
return $matches;
}
}
}