Skip to content

Commit

Permalink
Flatten the code
Browse files Browse the repository at this point in the history
Remove used-once intermediary variables, and move the pluginSplit call
to where it's used
  • Loading branch information
AD7six committed Feb 10, 2015
1 parent d3aae7e commit b79cc70
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/ORM/TableRegistry.php
Expand Up @@ -155,21 +155,18 @@ public static function config($alias = null, $options = null)
*/
public static function get($alias, array $options = [])
{
list(, $classAlias) = pluginSplit($alias);
$exists = isset(static::$_instances[$alias]);

if ($exists && !empty($options)) {
if (static::$_options[$alias] !== $options) {
if (isset(static::$_instances[$alias])) {
if (!empty($options) && static::$_options[$alias] !== $options) {
throw new RuntimeException(sprintf(
'You cannot configure "%s", it already exists in the registry.',
$alias
));
}
}
if ($exists) {
return static::$_instances[$alias];
}

static::$_options[$alias] = $options;
list(, $classAlias) = pluginSplit($alias);
$options = ['alias' => $classAlias] + $options;

if (empty($options['className'])) {
Expand Down

0 comments on commit b79cc70

Please sign in to comment.