From 85c93c3e0c1bb8de7a672ded6f24347dc5e2a836 Mon Sep 17 00:00:00 2001 From: Dan Cryer Date: Mon, 12 May 2014 17:01:05 +0100 Subject: [PATCH] Reducing complexity of ProjectController::add() - See #384 --- PHPCI/Controller/ProjectController.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/PHPCI/Controller/ProjectController.php b/PHPCI/Controller/ProjectController.php index 90faf898..63a84fc6 100644 --- a/PHPCI/Controller/ProjectController.php +++ b/PHPCI/Controller/ProjectController.php @@ -178,23 +178,13 @@ class ProjectController extends \PHPCI\Controller $values = $form->getValues(); - if ($values['type'] == "gitlab") { - preg_match('`^(.*)@(.*):(.*)/(.*)\.git`', $values['reference'], $matches); - + $matches = array(); + if ($values['type'] == "gitlab" && preg_match('`^(.*)@(.*):(.*)/(.*)\.git`', $values['reference'], $matches)) { $info = array(); - if (isset($matches[1])) { - $info["user"] = $matches[1]; - } - - if (isset($matches[2])) { - $info["domain"] = $matches[2]; - } - + $info['user'] = $matches[1]; + $info['domain'] = $matches[2]; $values['access_information'] = serialize($info); - - if (isset($matches[3]) && isset($matches[4])) { - $values['reference'] = $matches[3]."/".$matches[4]; - } + $values['reference'] = $matches[3]."/".$matches[4]; } $values['git_key'] = $values['key'];