| @@ -110,8 +110,12 @@ | ||
| 110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly. | 
| 111 | 111 | // This means there is no diference between an empty string and a null | 
| 112 | 112 | // but "0" is considered to be non-empty. | 
| 113 | - if(empty($from) && !strlen($from)) $from = '-'; | |
| 114 | - if(empty($to) && !strlen($to)) $to = '-'; | |
| 113 | +		if(empty($from) && !strlen($from)) { | |
| 114 | + $from = '-'; | |
| 115 | + } | |
| 116 | +		if(empty($to) && !strlen($to)) { | |
| 117 | + $to = '-'; | |
| 118 | + } | |
| 115 | 119 | |
| 116 | 120 | return $this->changes[$title] = array( | 
| 117 | 121 | 'from' => $from, | 
| @@ -110,8 +110,8 @@ discard block | ||
| 110 | 110 | // Normalise "empty" values into dashes so comparisons are done properly. | 
| 111 | 111 | // This means there is no diference between an empty string and a null | 
| 112 | 112 | // but "0" is considered to be non-empty. | 
| 113 | - if(empty($from) && !strlen($from)) $from = '-'; | |
| 114 | - if(empty($to) && !strlen($to)) $to = '-'; | |
| 113 | + if (empty($from) && !strlen($from)) $from = '-'; | |
| 114 | + if (empty($to) && !strlen($to)) $to = '-'; | |
| 115 | 115 | |
| 116 | 116 | return $this->changes[$title] = array( | 
| 117 | 117 | 'from' => $from, | 
| @@ -170,7 +170,7 @@ discard block | ||
| 170 | 170 | */ | 
| 171 | 171 |  	public function getChange($key) { | 
| 172 | 172 | $changes = $this->getChanges(); | 
| 173 | -		if(array_key_exists($key, $changes)) { | |
| 173 | +		if (array_key_exists($key, $changes)) { | |
| 174 | 174 | return new ArrayData($changes[$key]); | 
| 175 | 175 | } | 
| 176 | 176 | return null; | 
| @@ -189,7 +189,7 @@ discard block | ||
| 189 | 189 | * @return string|null | 
| 190 | 190 | */ | 
| 191 | 191 |  	public function getOption($option) { | 
| 192 | -		if(!empty($this->options[$option])) { | |
| 192 | +		if (!empty($this->options[$option])) { | |
| 193 | 193 | return $this->options[$option]; | 
| 194 | 194 | } | 
| 195 | 195 | } | 
| @@ -230,7 +230,7 @@ discard block | ||
| 230 | 230 | DeploymentStrategy::WARNING_CODE => 1, | 
| 231 | 231 | DeploymentStrategy::ERROR_CODE => 2 | 
| 232 | 232 | ]; | 
| 233 | -		if($map[$current] < $map[$code]) { | |
| 233 | +		if ($map[$current] < $map[$code]) { | |
| 234 | 234 | $this->setValidationCode($code); | 
| 235 | 235 | } | 
| 236 | 236 | } | 
| @@ -259,7 +259,7 @@ discard block | ||
| 259 | 259 | ); | 
| 260 | 260 | |
| 261 | 261 | $output = array(); | 
| 262 | -		foreach($fields as $field) { | |
| 262 | +		foreach ($fields as $field) { | |
| 263 | 263 | $output[$field] = $this->$field; | 
| 264 | 264 | } | 
| 265 | 265 | return $output; | 
| @@ -300,8 +300,8 @@ discard block | ||
| 300 | 300 | 'messages' | 
| 301 | 301 | ); | 
| 302 | 302 | |
| 303 | -		foreach($fields as $field) { | |
| 304 | -			if(!empty($data[$field])) { | |
| 303 | +		foreach ($fields as $field) { | |
| 304 | +			if (!empty($data[$field])) { | |
| 305 | 305 | $this->$field = $data[$field]; | 
| 306 | 306 | } | 
| 307 | 307 | } | 
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | * Do the actual job by calling the appropiate backend | 
| 32 | 32 | */ | 
| 33 | 33 |  	public function perform() { | 
| 34 | - echo "[-] PingJob starting" . PHP_EOL; | |
| 34 | + echo "[-] PingJob starting".PHP_EOL; | |
| 35 | 35 | $log = new DeploynautLogFile($this->args['logfile']); | 
| 36 | 36 | |
| 37 | 37 | $ping = DNPing::get()->byID($this->args['pingID']); | 
| @@ -205,12 +205,16 @@ | ||
| 205 | 205 | */ | 
| 206 | 206 |  	public function getFullDeployMessages() { | 
| 207 | 207 | $strategy = $this->getDeploymentStrategy(); | 
| 208 | - if ($strategy->getActionCode()!=='full') return null; | |
| 208 | +		if ($strategy->getActionCode()!=='full') { | |
| 209 | + return null; | |
| 210 | + } | |
| 209 | 211 | |
| 210 | 212 | $changes = $strategy->getChangesModificationNeeded(); | 
| 211 | 213 | $messages = []; | 
| 212 | 214 |  		foreach ($changes as $change => $details) { | 
| 213 | - if ($change==='Code version') continue; | |
| 215 | +			if ($change==='Code version') { | |
| 216 | + continue; | |
| 217 | + } | |
| 214 | 218 | |
| 215 | 219 | $messages[] = [ | 
| 216 | 220 | 'Flag' => sprintf( | 
| @@ -108,7 +108,7 @@ discard block | ||
| 108 | 108 | } | 
| 109 | 109 | |
| 110 | 110 |  	public function LogLink() { | 
| 111 | - return $this->Link() . '/log'; | |
| 111 | + return $this->Link().'/log'; | |
| 112 | 112 | } | 
| 113 | 113 | |
| 114 | 114 |  	public function canView($member = null) { | 
| @@ -154,7 +154,7 @@ discard block | ||
| 154 | 154 | * @return \Gitonomy\Git\Repository|null | 
| 155 | 155 | */ | 
| 156 | 156 |  	public function getRepository() { | 
| 157 | -		if(!$this->SHA) { | |
| 157 | +		if (!$this->SHA) { | |
| 158 | 158 | return null; | 
| 159 | 159 | } | 
| 160 | 160 | return $this->Environment()->Project()->getRepository(); | 
| @@ -167,10 +167,10 @@ discard block | ||
| 167 | 167 | */ | 
| 168 | 168 |  	public function getCommit() { | 
| 169 | 169 | $repo = $this->getRepository(); | 
| 170 | -		if($repo) { | |
| 170 | +		if ($repo) { | |
| 171 | 171 |  			try { | 
| 172 | 172 | return $this->Environment()->getCommit($this->SHA); | 
| 173 | -			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { | |
| 173 | +			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $ex) { | |
| 174 | 174 | return null; | 
| 175 | 175 | } | 
| 176 | 176 | } | 
| @@ -195,7 +195,7 @@ discard block | ||
| 195 | 195 |  		if (!$interface) { | 
| 196 | 196 | return null; | 
| 197 | 197 | } | 
| 198 | - return $interface->CommitURL . '/' . $this->SHA; | |
| 198 | + return $interface->CommitURL.'/'.$this->SHA; | |
| 199 | 199 | } | 
| 200 | 200 | |
| 201 | 201 | /** | 
| @@ -205,10 +205,10 @@ discard block | ||
| 205 | 205 | */ | 
| 206 | 206 |  	public function getCommitMessage() { | 
| 207 | 207 | $commit = $this->getCommit(); | 
| 208 | -		if($commit) { | |
| 208 | +		if ($commit) { | |
| 209 | 209 |  			try { | 
| 210 | 210 | return Convert::raw2xml($this->Environment()->getCommitMessage($commit)); | 
| 211 | -			} catch(Gitonomy\Git\Exception\ReferenceNotFoundException $e) { | |
| 211 | +			} catch (Gitonomy\Git\Exception\ReferenceNotFoundException $e) { | |
| 212 | 212 | return null; | 
| 213 | 213 | } | 
| 214 | 214 | } | 
| @@ -225,7 +225,7 @@ discard block | ||
| 225 | 225 | $this->Environment()->getCommitTags($commit); | 
| 226 | 226 | $returnTags = []; | 
| 227 | 227 |  		if (!empty($tags)) { | 
| 228 | -			foreach($tags as $tag) { | |
| 228 | +			foreach ($tags as $tag) { | |
| 229 | 229 |  				$field = Varchar::create('Tag', '255'); | 
| 230 | 230 | $field->setValue($tag->getName()); | 
| 231 | 231 | $returnTags[] = $field; | 
| @@ -242,12 +242,12 @@ discard block | ||
| 242 | 242 | */ | 
| 243 | 243 |  	public function getFullDeployMessages() { | 
| 244 | 244 | $strategy = $this->getDeploymentStrategy(); | 
| 245 | - if ($strategy->getActionCode()!=='full') return null; | |
| 245 | + if ($strategy->getActionCode() !== 'full') return null; | |
| 246 | 246 | |
| 247 | 247 | $changes = $strategy->getChangesModificationNeeded(); | 
| 248 | 248 | $messages = []; | 
| 249 | 249 |  		foreach ($changes as $change => $details) { | 
| 250 | - if ($change==='Code version') continue; | |
| 250 | + if ($change === 'Code version') continue; | |
| 251 | 251 | |
| 252 | 252 | $messages[] = [ | 
| 253 | 253 | 'Flag' => sprintf( | 
| @@ -275,7 +275,7 @@ discard block | ||
| 275 | 275 | */ | 
| 276 | 276 |  	public function getTag() { | 
| 277 | 277 | $tags = $this->getTags(); | 
| 278 | -		if($tags->count() > 0) { | |
| 278 | +		if ($tags->count() > 0) { | |
| 279 | 279 | return $tags->last(); | 
| 280 | 280 | } | 
| 281 | 281 | return null; | 
| @@ -300,7 +300,7 @@ discard block | ||
| 300 | 300 |  	public function getChanges() { | 
| 301 | 301 | $list = new ArrayList(); | 
| 302 | 302 | $strategy = $this->getDeploymentStrategy(); | 
| 303 | -		foreach($strategy->getChanges() as $name => $change) { | |
| 303 | +		foreach ($strategy->getChanges() as $name => $change) { | |
| 304 | 304 | $changed = (isset($change['from']) && isset($change['to'])) ? $change['from'] != $change['to'] : null; | 
| 305 | 305 | $description = isset($change['description']) ? $change['description'] : ''; | 
| 306 | 306 | $compareUrl = null; | 
| @@ -350,11 +350,11 @@ discard block | ||
| 350 | 350 | // Make sure we use the SHA as it was written into this DNDeployment. | 
| 351 | 351 | $args['sha'] = $this->SHA; | 
| 352 | 352 | |
| 353 | -		if(!$this->DeployerID) { | |
| 353 | +		if (!$this->DeployerID) { | |
| 354 | 354 | $this->DeployerID = Member::currentUserID(); | 
| 355 | 355 | } | 
| 356 | 356 | |
| 357 | -		if($this->DeployerID) { | |
| 357 | +		if ($this->DeployerID) { | |
| 358 | 358 | $deployer = $this->Deployer(); | 
| 359 | 359 | $message = sprintf( | 
| 360 | 360 | 'Deploy to %s initiated by %s (%s), with IP address %s', | 
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | substr($sha, 0, 8), | 
| 74 | 74 | $branch->LastUpdated()->TimeDiff() | 
| 75 | 75 | ); | 
| 76 | - $branches[$sha . '-' . $name] = $branchValue; | |
| 76 | + $branches[$sha.'-'.$name] = $branchValue; | |
| 77 | 77 | } | 
| 78 | 78 | |
| 79 | 79 | // Tags | 
| @@ -86,7 +86,7 @@ discard block | ||
| 86 | 86 | substr($sha, 0, 8), | 
| 87 | 87 | $branch->LastUpdated()->TimeDiff() | 
| 88 | 88 | ); | 
| 89 | - $tags[$sha . '-' . $tag] = $tagValue; | |
| 89 | + $tags[$sha.'-'.$tag] = $tagValue; | |
| 90 | 90 | } | 
| 91 | 91 | $tags = array_reverse($tags); | 
| 92 | 92 | |
| @@ -58,7 +58,9 @@ | ||
| 58 | 58 | |
| 59 | 59 |  	protected function addHandlers($machine) { | 
| 60 | 60 | $class = get_class($machine->getObject()); | 
| 61 | - if (empty($this->config()->handlers[$class])) return; | |
| 61 | +		if (empty($this->config()->handlers[$class])) { | |
| 62 | + return; | |
| 63 | + } | |
| 62 | 64 | |
| 63 | 65 | $transitions = $this->config()->handlers[$class]; | 
| 64 | 66 |  		foreach ($transitions as $transName => $handlers) { | 
| @@ -10,7 +10,7 @@ | ||
| 10 | 10 | // This will ensure jobs can correctly clean themselves up on any type of failure | 
| 11 | 11 |  Resque_Event::listen('onFailure', function(Exception $exception, Resque_job $job) { | 
| 12 | 12 | $inst = $job->getInstance(); | 
| 13 | -	if($inst instanceof DeploynautJobInterface) { | |
| 13 | +	if ($inst instanceof DeploynautJobInterface) { | |
| 14 | 14 | $inst->onFailure($exception); | 
| 15 | 15 | } | 
| 16 | 16 | }); | 
| @@ -96,7 +96,7 @@ | ||
| 96 | 96 | // It gives a chance to perform a dry-run, and reject the transition, for example | 
| 97 | 97 | // in case the user is unauthorised. | 
| 98 | 98 | 'finite.test_transition', | 
| 99 | -			function (Finite\Event\TransitionEvent $e) use ($project) { | |
| 99 | +			function(Finite\Event\TransitionEvent $e) use ($project) { | |
| 100 | 100 | $code = null; | 
| 101 | 101 | |
| 102 | 102 |  				switch ($e->getTransition()->getName()) { | 
| @@ -133,7 +133,7 @@ discard block | ||
| 133 | 133 |  	protected function getUpdateStatus($ID) { | 
| 134 | 134 | $ping = DNGitFetch::get()->byID($ID); | 
| 135 | 135 |  		if (!$ping) { | 
| 136 | -			return $this->getAPIResponse(['message' => 'GIT update (' . $ID . ') not found'], 404); | |
| 136 | +			return $this->getAPIResponse(['message' => 'GIT update ('.$ID.') not found'], 404); | |
| 137 | 137 | } | 
| 138 | 138 | $output = [ | 
| 139 | 139 | 'id' => $ID, | 
| @@ -154,7 +154,7 @@ discard block | ||
| 154 | 154 | $fetch->write(); | 
| 155 | 155 | $fetch->start(); | 
| 156 | 156 | |
| 157 | - $location = Director::absoluteBaseURL() . $this->Link() . '/update/' . $fetch->ID; | |
| 157 | + $location = Director::absoluteBaseURL().$this->Link().'/update/'.$fetch->ID; | |
| 158 | 158 | $output = [ | 
| 159 | 159 | 'message' => 'git fetch has been queued', | 
| 160 | 160 | 'id' => $fetch->ID, | 
| @@ -50,14 +50,14 @@ | ||
| 50 | 50 | */ | 
| 51 | 51 |  	public function getPackageFilename($identifier, $sha, $repositoryDir, DeploynautLogFile $log) { | 
| 52 | 52 | // Fetch through the cache | 
| 53 | -		if($this->cache) { | |
| 54 | - $identifier .= '-' . get_class($this) . '-' . $this->getIdentifier(); | |
| 53 | +		if ($this->cache) { | |
| 54 | + $identifier .= '-'.get_class($this).'-'.$this->getIdentifier(); | |
| 55 | 55 | return $this->cache->getPackageFilename($this, $identifier, $sha, $repositoryDir, $log); | 
| 56 | 56 | |
| 57 | 57 | // Default, cacheless implementation | 
| 58 | 58 |   		} else { | 
| 59 | - $filename = TEMP_FOLDER . '/' . $sha . '.tar.gz'; | |
| 60 | - 			if($this->generatePackage($sha, $repositoryDir, $filename, $log)) { | |
| 59 | + $filename = TEMP_FOLDER.'/'.$sha.'.tar.gz'; | |
| 60 | + 			if ($this->generatePackage($sha, $repositoryDir, $filename, $log)) { | |
| 61 | 61 | return $filename; | 
| 62 | 62 | } | 
| 63 | 63 | } |