Skip to content

Commit

Permalink
updated deps, fixed CI
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalkaoz committed Mar 30, 2016
1 parent 68d2a45 commit 6290bf0
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 125 deletions.
232 changes: 147 additions & 85 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/Console/CommandFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function getMatchers()
'onlyContainCommandInstances' => function ($subject) {
foreach ($subject as $command) {
if (!$command instanceof Command) {
throw new FailureException('"'.get_class($command).'" is not a subtype of Symfony\Component\Console\Command\Command');
throw new FailureException('"' . get_class($command) . '" is not a subtype of Symfony\Component\Console\Command\Command');
}
}

Expand Down
2 changes: 1 addition & 1 deletion spec/Output/ProjectsSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ private function defaultOutput($method)
'version_current' => '2.5.0',
'version_requested' => '2.5.0',
'licenses' => [['name' => 'MIT']],
'security_vulnerabilities' => [['cve' => 'lolcat']],
'security_vulnerabilities' => [['cve' => 'lolcat']],
]],
]);

Expand Down
6 changes: 3 additions & 3 deletions src/Api/BaseApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ abstract class BaseApi
public function __construct(HttpClient $client, $token = null)
{
$this->client = $client;
$this->token = $token;
$this->token = $token;
}

/**
Expand Down Expand Up @@ -78,7 +78,7 @@ protected function transform($name)
private function sanitizeQuery($query)
{
$parts = parse_url($query);
$path = $parts['path'];
$path = $parts['path'];

if (!isset($parts['query'])) {
return $query;
Expand All @@ -101,7 +101,7 @@ private function sanitizeQuery($query)
}
}

return $path.'?'.http_build_query($final);
return $path . '?' . http_build_query($final);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Github.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function sync()
*/
public function show($repository)
{
return $this->request('github/'.$this->transform($repository));
return $this->request('github/' . $this->transform($repository));
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function all()
*/
public function show($project)
{
return $this->request('projects/'.$project);
return $this->request('projects/' . $project);
}

/**
Expand All @@ -42,7 +42,7 @@ public function show($project)
*/
public function delete($project)
{
return $this->request('projects/'.$project, 'DELETE');
return $this->request('projects/' . $project, 'DELETE');
}

/**
Expand All @@ -67,7 +67,7 @@ public function create($file)
*/
public function update($project, $file)
{
return $this->request('projects/'.$project, 'POST', ['project_file' => $file]);
return $this->request('projects/' . $project, 'POST', ['project_file' => $file]);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Api/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Users extends BaseApi implements Api
*/
public function show($username)
{
return $this->request('users/'.$username);
return $this->request('users/' . $username);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Authentication/RubyConfigFileToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RubyConfigFileToken implements Token
public function __construct($file = null)
{
if (null === $file) {
$file = $_SERVER['HOME'].DIRECTORY_SEPARATOR.'.veye.rc';
$file = $_SERVER['HOME'] . DIRECTORY_SEPARATOR . '.veye.rc';
}

$this->file = $file;
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ public function __construct(HttpClient $client = null, $url = 'https://www.versi
*/
public function api($name)
{
$class = 'Rs\\VersionEye\\Api\\'.ucfirst($name);
$class = 'Rs\\VersionEye\\Api\\' . ucfirst($name);

if (class_exists($class)) {
return new $class($this->client, $this->token);
} else {
throw new \InvalidArgumentException('unknown api "'.$name.'" requested');
throw new \InvalidArgumentException('unknown api "' . $name . '" requested');
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/Console/CommandFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class CommandFactory
public function __construct(Token $token, CaseTransformerInterface $transformer)
{
$this->transformer = $transformer;
$this->token = $token;
$this->token = $token;
}

/**
Expand All @@ -47,16 +47,16 @@ public function __construct(Token $token, CaseTransformerInterface $transformer)
*/
public function generateCommands(array $classes = [])
{
$classes = $this->readApis($classes);
$token = $this->token->read();
$classes = $this->readApis($classes);
$token = $this->token->read();
$commands = [];

foreach ($classes as $class) {
$api = new \ReflectionClass($class);

foreach ($api->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
if (0 !== strpos($method->getName(), '__')) { //skip magics
$command = $this->generateCommand($api->getShortName(), $method, $token);
$command = $this->generateCommand($api->getShortName(), $method, $token);
$commands[$command->getName()] = $command;
}
}
Expand All @@ -78,7 +78,7 @@ private function generateCommand($name, \ReflectionMethod $method, $token = null
{
$methodName = $this->transformer->transform($method->getName());

$command = new Command(strtolower($name.':'.$methodName));
$command = new Command(strtolower($name . ':' . $methodName));
$docBlock = new DocBlock($method->getDocComment());

$command->setDefinition($this->buildDefinition($method, $token));
Expand Down Expand Up @@ -133,9 +133,9 @@ private function createCode($name, \ReflectionMethod $method)
$client->authorize($input->getOption('token'));
}

$methodName = $method->getName();
$api = $client->api(strtolower($name));
$args = (new NamedArgumentsResolver($method))->resolve(array_merge($input->getOptions(), $input->getArguments()));
$methodName = $method->getName();
$api = $client->api(strtolower($name));
$args = (new NamedArgumentsResolver($method))->resolve(array_merge($input->getOptions(), $input->getArguments()));
$outputClass = $this->generateOutputClassFromApiClass($api);

$response = call_user_func_array([$api, $methodName], $args);
Expand Down Expand Up @@ -181,9 +181,9 @@ private function readApis(array $classes = [])
private function generateOutputClassFromApiClass(Api $api)
{
$classParts = explode('\\', get_class($api));
$apiName = array_pop($classParts);
$apiName = array_pop($classParts);
array_pop($classParts);

return implode('\\', $classParts).'\\Output\\'.$apiName;
return implode('\\', $classParts) . '\\Output\\' . $apiName;
}
}
10 changes: 5 additions & 5 deletions src/Http/IvoryHttpAdapterClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class IvoryHttpAdapterClient implements HttpClient
public function __construct(HttpAdapterInterface $adapter, $url)
{
$this->adapter = $adapter;
$this->url = $url;
$this->url = $url;
}

/**
Expand All @@ -37,7 +37,7 @@ public function request($method, $url, array $params = [])
list($params, $files) = $this->fixParams($params);

try {
$response = $this->adapter->send($this->url.$url, $method, [], $params, $files);
$response = $this->adapter->send($this->url . $url, $method, [], $params, $files);

return json_decode($response->getBody(), true);
} catch (HttpAdapterException $e) {
Expand All @@ -55,7 +55,7 @@ public function request($method, $url, array $params = [])
private function fixParams(array $params)
{
$parameters = [];
$files = [];
$files = [];

foreach ($params as $name => $value) {
if (is_readable($value)) { //file
Expand All @@ -77,9 +77,9 @@ private function fixParams(array $params)
*/
private function buildRequestError(HttpAdapterException $e)
{
$data = $e->getResponse() ? json_decode($e->getResponse()->getBody(), true) : ['error' => $e->getMessage()];
$data = $e->getResponse() ? json_decode($e->getResponse()->getBody(), true) : ['error' => $e->getMessage()];
$message = isset($data['error']) ? $data['error'] : 'Server Error';
$status = $e->getResponse() ? $e->getResponse()->getStatusCode() : 500;
$status = $e->getResponse() ? $e->getResponse()->getStatusCode() : 500;

return new CommunicationException(sprintf('%s : %s', $status, $message));
}
Expand Down
16 changes: 8 additions & 8 deletions src/Http/Pager.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
*/
class Pager implements \Iterator
{
private $offset = 0;
private $offset = 0;
private $current = 1;
private $max = 0;
private $result = [];
private $max = 0;
private $result = [];

/**
* @var HttpClient
Expand All @@ -34,13 +34,13 @@ class Pager implements \Iterator
public function __construct(array $result, $key, HttpClient $client, $method, $url, array $params = [])
{
$this->current = $result['paging']['current_page'];
$this->max = $result['paging']['total_entries'];
$this->result = $result[$key];
$this->max = $result['paging']['total_entries'];
$this->result = $result[$key];

$this->key = $key;
$this->key = $key;
$this->client = $client;
$this->method = $method;
$this->url = $url;
$this->url = $url;
$this->params = $params;
}

Expand Down Expand Up @@ -75,7 +75,7 @@ public function valid()
{
if (!isset($this->result[$this->offset]) && $this->offset < $this->max) {
++$this->current;
$url = preg_replace('/page=[0-9]+/', 'page='.$this->current, $this->url);
$url = preg_replace('/page=[0-9]+/', 'page=' . $this->current, $this->url);
$result = $this->client->request($this->method, $url, $this->params);

$this->result = array_merge($this->result, $result[$this->key]);
Expand Down
6 changes: 3 additions & 3 deletions src/Output/BaseOutput.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ protected function printTable(OutputInterface $output, array $headings, array $k
protected function printBoolean(OutputInterface $output, $success, $fail, $value, $line = true)
{
if ($value) {
$message = '<info>'.$success.'</info>';
$message = '<info>' . $success . '</info>';
} else {
$message = '<error>'.$fail.'</error>';
$message = '<error>' . $fail . '</error>';
}

if (false === $line) {
Expand All @@ -78,7 +78,7 @@ protected function printBoolean(OutputInterface $output, $success, $fail, $value
protected function printList(OutputInterface $output, array $headings, array $keys, array $data, \Closure $callback = null)
{
$width = $this->getColumnWidth($headings);
$data = array_merge(array_flip($keys), array_intersect_key($data, array_flip($keys)));
$data = array_merge(array_flip($keys), array_intersect_key($data, array_flip($keys)));

foreach ($headings as $key => $heading) {
$value = array_values($data)[$key];
Expand Down
2 changes: 1 addition & 1 deletion src/Output/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function licenses(OutputInterface $output, array $response)

foreach ($response['licenses'] as $license => $projects) {
foreach ($projects as $project) {
$name = $license === 'unknown' ? '<error>'.$project['name'].'</error>' : $project['name'];
$name = $license === 'unknown' ? '<error>' . $project['name'] . '</error>' : $project['name'];
$license = $license === 'unknown' ? '<error>unknown</error>' : $license;

$table->addRow([$license, $name]);
Expand Down

0 comments on commit 6290bf0

Please sign in to comment.