Skip to content

Commit

Permalink
CS fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
nrk committed Jul 8, 2012
1 parent e02ce26 commit 228659a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/multiple.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
));

/** routes **/
$app->get('/', function() use($app) {
$app->get('/', function () use ($app) {
$first = var_export($app['predis.first']->info(), true);
$second = var_export($app['predis.second']->info(), true);
$third = var_export($app['predis.third']->info(), true);
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
));

/** routes **/
$app->get('/', function() use($app) {
$app->get('/', function () use ($app) {
return var_export($app['predis']->info(), true);
});

Expand Down
19 changes: 10 additions & 9 deletions lib/Predis/Silex/PredisServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function boot(Application $app)
throw new \InvalidArgumentException("The specified alias '$alias' is not valid.");
}

$app["$prefix.$alias"] = $app->share(function() use($app, $prefix, $args) {
$app["$prefix.$alias"] = $app->share(function () use ($app, $prefix, $args) {
$initializer = $app["$prefix.client_initializer"];

if (!isset($args['parameters'])) {
Expand All @@ -76,14 +76,13 @@ public function boot(Application $app)
});

if (is_array($args) && isset($args['default']) && $args['default'] == true) {
$app[$prefix] = $app->share(function() use($app, $prefix, $alias) {
$app[$prefix] = $app->share(function () use ($app, $prefix, $alias) {
return $app["$prefix.$alias"];
});
}
}
}
else {
$app[$prefix] = $app->share(function() use($app, $prefix) {
} else {
$app[$prefix] = $app->share(function () use ($app, $prefix) {
$initializer = $app["$prefix.client_initializer"];

return $initializer($app);
Expand All @@ -98,15 +97,18 @@ public function register(Application $app)
{
$prefix = $this->prefix;

$app["$prefix.client_initializer"] = $app->protect(function($arguments) use($app, $prefix) {
$extract = function($bag, $key) use ($app, $prefix) {
$app["$prefix.client_initializer"] = $app->protect(function ($arguments) use ($app, $prefix) {
$extract = function ($bag, $key) use ($app, $prefix) {
$default = "default_$key";

if ($bag instanceof Application) {
$key = "$prefix.$key";
}

if (!isset($bag[$key])) {
return $app["$prefix.$default"];
}

if (is_array($bag[$key])) {
return array_merge($app["$prefix.$default"], $bag[$key]);
}
Expand All @@ -117,8 +119,7 @@ public function register(Application $app)
if (is_string($arguments)) {
$parameters = $arguments;
$options = $app["$prefix.default_options"];
}
else {
} else {
$parameters = $extract($arguments, 'parameters');
$options = $extract($arguments, 'options');
}
Expand Down

0 comments on commit 228659a

Please sign in to comment.