Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
zendframework/zendframework#6078 - minor CS fixes/cleanups in `MongoD…
Browse files Browse the repository at this point in the history
…BOptions` implementation
  • Loading branch information
Ocramius committed Nov 13, 2014
1 parent 90f7c0f commit 8e95bcc
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions src/Storage/Adapter/MongoDBOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,37 +13,42 @@ class MongoDBOptions extends AdapterOptions
{
/**
* The namespace separator
*
* @var string
*/
protected $namespaceSeparator = ':';
private $namespaceSeparator = ':';

/**
* The redis resource manager
*
* @var null|RedisResourceManager
*/
protected $resourceManager;
private $resourceManager;

/**
* The resource id of the resource manager
*
* @var string
*/
protected $resourceId = 'default';
private $resourceId = 'default';

/**
* Set namespace separator
*
* @param string $namespaceSeparator
* @return RedisOptions
*
* @return self
*/
public function setNamespaceSeparator($namespaceSeparator)
{
$namespaceSeparator = (string) $namespaceSeparator;

if ($this->namespaceSeparator !== $namespaceSeparator) {
$this->triggerOptionEvent('namespace_separator', $namespaceSeparator);

$this->namespaceSeparator = $namespaceSeparator;
}

return $this;
}

Expand All @@ -61,14 +66,17 @@ public function getNamespaceSeparator()
* Set the mongodb resource manager to use
*
* @param null|MongoDBResourceManager $resourceManager
* @return MongoDBOptions
*
* @return self
*/
public function setResourceManager(MongoDBResourceManager $resourceManager = null)
{
if ($this->resourceManager !== $resourceManager) {
$this->triggerOptionEvent('resource_manager', $resourceManager);

$this->resourceManager = $resourceManager;
}

return $this;
}

Expand All @@ -79,10 +87,7 @@ public function setResourceManager(MongoDBResourceManager $resourceManager = nul
*/
public function getResourceManager()
{
if (!$this->resourceManager) {
$this->resourceManager = new MongoDBResourceManager();
}
return $this->resourceManager;
return $this->resourceManager ?: $this->resourceManager = new MongoDBResourceManager();
}

/**
Expand All @@ -99,28 +104,34 @@ public function getResourceId()
* Set the redis resource id
*
* @param string $resourceId
* @return MongoDBOptions
*
* @return self
*/
public function setResourceId($resourceId)
{
$resourceId = (string) $resourceId;

if ($this->resourceId !== $resourceId) {
$this->triggerOptionEvent('resource_id', $resourceId);

$this->resourceId = $resourceId;
}

return $this;
}

/**
* set mongo options
*
* @param array $libOptions
* @return MongoDBOptions
*
* @return self
*/
public function setLibOptions(array $libOptions)
{
$this->triggerOptionEvent('lib_option', $libOptions);
$this->getResourceManager()->setLibOptions($this->getResourceId(), $libOptions);

return $this;
}
}

0 comments on commit 8e95bcc

Please sign in to comment.