Skip to content

Commit

Permalink
added gettters + setters; removed rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
limenet committed Feb 18, 2017
1 parent abab0df commit 1c02da4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
"description": "Deploy a new version using a GitHub webhook",
"type": "library",
"require": {
"symfony/http-foundation": "^3.1",
"php-curl-class/php-curl-class": "^7.0"
"symfony/http-foundation": "^3.1"
},
"autoload": {
"psr-4": {
Expand Down
49 changes: 21 additions & 28 deletions src/limenet/Deploy/Deploy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace limenet\Deploy;

use Curl\Curl;
use ReflectionClass;
use Symfony\Component\HttpFoundation\IpUtils;
use Symfony\Component\HttpFoundation\Request;
Expand All @@ -27,40 +26,50 @@ class Deploy

private $postDeployAdapters;

public function addAdapter(AdapterInterface $adapter)
public function addAdapter(AdapterInterface $adapter) : void
{
$reflect = new ReflectionClass($adapter);
if ($reflect->implementsInterface(PostDeployAdapterInterface::class)) {
$this->postDeployAdapters[] = $adapter;
}
}

public function basepath(string $basepath)
public function getBasepath() : string
{
return $this->basepath;
}

public function setBasepath(string $basepath) : void
{
$this->basepath = $basepath;
}

public function branch(string $branch)
public function getBranch() : string
{
return $this->branch;
}

public function setBranch(string $branch) : void
{
$this->branch = $branch;
}

public function env(string $env)
public function getEnv() : string
{
$this->env = $env;
return $this->env;
}

public function rollbar(array $rollbar)
public function setEnv(string $env) : void
{
$this->rollbar = $rollbar;
$this->env = $env;
}

public function version(callable $version)
public function setVersion(callable $version) : void
{
$this->version = $version;
}

public function cleanCache(callable $cleanCache)
public function setCleanCache(callable $cleanCache) : void
{
$this->cleanCache = $cleanCache;
}
Expand All @@ -83,7 +92,7 @@ private function runCleanCache()
return false;
}

public function run()
public function run() : void
{
if (!$this->checkValidRequest()) {
header('HTTP/1.1 403 Unauthorized', true, 403);
Expand Down Expand Up @@ -151,7 +160,7 @@ protected function checkBranch() : bool
*
* @return array
*/
protected function updateCode()
protected function updateCode() : array
{
$output = [];
$returnValue = 0;
Expand Down Expand Up @@ -179,20 +188,4 @@ protected function updateCode()
'returnValue' => $returnValue,
];
}

/**
* Notifies Rollbar about the new version.
*
* @return void
*/
protected function rollbarDeploy()
{
$curl = new Curl();
$curl->post('https://api.rollbar.com/api/1/deploy/', [
'access_token' => $this->rollbar['token'],
'environment' => $this->env,
'revision' => $this->getVersion(),
'local_username' => 'limenet/deploy',
]);
}
}

0 comments on commit 1c02da4

Please sign in to comment.