Skip to content

Commit

Permalink
Applied fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz authored and StyleCIBot committed Sep 27, 2015
1 parent 65494ae commit 9c411e1
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 31 deletions.
1 change: 1 addition & 0 deletions src/Application.php
Expand Up @@ -21,6 +21,7 @@ protected function getDefaultCommands()
$commands = parent::getDefaultCommands();
$commands[] = new UpdateCommand();
$commands[] = new ListCommand();

return $commands;
}
}
9 changes: 4 additions & 5 deletions src/Commands/AbstractCommand.php
@@ -1,7 +1,6 @@
<?php
namespace Onigoetz\Dyn53\Commands;

use Aws\Common\Exception\LogicException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
Expand Down Expand Up @@ -33,10 +32,10 @@ protected function configure()

protected function readConfig(InputInterface $input)
{
$config = array();
$config = [];
$file = $input->getOption('config');
if ($file) {
if(!file_exists($file)) {
if (!file_exists($file)) {
throw new \LogicException("the file '$file' doesn't exist");
}

Expand All @@ -59,7 +58,7 @@ protected function fillTheBlanks($config)

protected function getParameters()
{
$parameters = array();
$parameters = [];

foreach ($this->getDefinition()->getOptions() as $option) {
if ($option->getName() != 'config') {
Expand All @@ -72,7 +71,7 @@ protected function getParameters()

protected function getMandatoryParameters()
{
return array('key', 'secret');
return ['key', 'secret'];
}

protected function getConfiguration(InputInterface $input)
Expand Down
10 changes: 4 additions & 6 deletions src/Commands/ListCommand.php
Expand Up @@ -3,12 +3,10 @@

use Aws\Route53\Route53Client;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class ListCommand extends AbstractCommand
{

protected function configure()
{
parent::configure();
Expand All @@ -22,17 +20,17 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$config = $this->getConfiguration($input);

$client = Route53Client::factory(array('key' => $config['key'], 'secret' => $config['secret']));
$client = Route53Client::factory(['key' => $config['key'], 'secret' => $config['secret']]);

$result = $client->listHostedZones();

$content = array();
$content = [];
foreach ($result['HostedZones'] as $zone) {
$content[] = array($zone['Name'], $zone['Id']);
$content[] = [$zone['Name'], $zone['Id']];
}

$table = $this->getHelperSet()->get('table');
$table->setHeaders(array('Name', 'ID'))->setRows($content);
$table->setHeaders(['Name', 'ID'])->setRows($content);
$table->render($output);
}
}
34 changes: 17 additions & 17 deletions src/Commands/UpdateCommand.php
Expand Up @@ -55,12 +55,12 @@ protected function getMandatoryParameters()
protected function getCurrentRecord(Route53Client $client, $config)
{
return $client->listResourceRecordSets(
array(
[
'HostedZoneId' => $config['zone'],
'StartRecordName' => $config['domain'],
'StartRecordType' => 'A',
'MaxItems' => 1
)
'MaxItems' => 1,
]
);
}

Expand Down Expand Up @@ -88,28 +88,28 @@ protected function needsUpdate($config, $result)
protected function applyUpdate($client, $config)
{
$client->changeResourceRecordSets(
array(
[
// HostedZoneId is required
'HostedZoneId' => $config['zone'],
// ChangeBatch is required
'ChangeBatch' => array(
'ChangeBatch' => [
'Comment' => 'An IP address change was detected; updating',
// Changes is required
'Changes' => array(
array(
'Changes' => [
[
// Action is required
'Action' => 'UPSERT',
// ResourceRecordSet is required
'ResourceRecordSet' => array(
'ResourceRecordSet' => [
'Name' => $config['domain'],
'Type' => 'A',
'TTL' => '60',
'ResourceRecords' => array(array('Value' => $config['ip']))
)
)
),
),
)
'ResourceRecords' => [['Value' => $config['ip']]],
],
],
],
],
]
);
}

Expand All @@ -124,16 +124,16 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

//open connection to R53
$client = Route53Client::factory(array('key' => $config['key'], 'secret' => $config['secret']));
$client = Route53Client::factory(['key' => $config['key'], 'secret' => $config['secret']]);

$current = $this->getCurrentRecord($client, $config);

if ($this->needsUpdate($config, $current)) {
$result = $this->applyUpdate($client, $config);

$output->writeln("Updated IP to : " . $config['ip']);
$output->writeln('Updated IP to : ' . $config['ip']);
} else {
$output->writeln("Nothing to update");
$output->writeln('Nothing to update');
}
}
}
4 changes: 2 additions & 2 deletions src/Compiler.php
Expand Up @@ -21,8 +21,8 @@ class Compiler
/**
* Compiles composer into a single phar file
*
* @throws \RuntimeException
* @param string $pharFile The full path to the file to create
* @throws \RuntimeException
*/
public function compile($pharFile = 'dyn53.phar')
{
Expand Down Expand Up @@ -124,7 +124,7 @@ private function stripWhitespace($source)
foreach (token_get_all($source) as $token) {
if (is_string($token)) {
$output .= $token;
} elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) {
} elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
$output .= str_repeat("\n", substr_count($token[1], "\n"));
} elseif (T_WHITESPACE === $token[0]) {
// reduce wide spaces
Expand Down
1 change: 0 additions & 1 deletion src/Policies/MyExternalIP.php
Expand Up @@ -9,7 +9,6 @@
*/
class MyExternalIP implements ResolverPolicy
{

public function getIP()
{
//TODO :: use guzzle
Expand Down

0 comments on commit 9c411e1

Please sign in to comment.