Permalink
Browse files

Update formatting to comply with Symfony2 standards

  • Loading branch information...
1 parent e16fb88 commit f4a76abb4ec0eaa9a584f9abeb7db27708500ede @jeremylivingston jeremylivingston committed Apr 2, 2013
View
222 Cache.php
@@ -6,136 +6,130 @@
use Beryllium\CacheBundle\CacheClientInterface;
/**
- * Cache
- *
+ * Cache
+ *
* @uses CacheInterface
- * @package
+ * @package
* @version $id$
- * @author Kevin Boyd <beryllium@beryllium.ca>
+ * @author Kevin Boyd <beryllium@beryllium.ca>
* @license See LICENSE.md
*/
class Cache implements CacheInterface
{
- public $dic = false;
+ public $dic = false;
- protected $client = null;
- protected $safe = false;
+ protected $client = null;
+ protected $safe = false;
- /**
- * Prep the cache
- *
- * @param CacheClientInterface $client Optional cache object/service
- * @access public
- * @return void
- */
- public function __construct( CacheClientInterface $client = null )
- {
- if ( !empty( $client ) )
- {
- if ( is_object( $client ) && ( $client instanceof CacheClientInterface ) )
- $this->client = $client;
- else
- {
- throw new \Exception( 'Invalid Cache Client Interface' );
- }
- }
- }
+ /**
+ * Prep the cache
+ *
+ * @param CacheClientInterface $client Optional cache object/service
+ * @access public
+ * @return void
+ */
+ public function __construct(CacheClientInterface $client = null)
+ {
+ if (!empty($client)) {
+ if (is_object($client) && ($client instanceof CacheClientInterface)) {
+ $this->client = $client;
+ }
+ else {
+ throw new \Exception('Invalid Cache Client Interface');
+ }
+ }
+ }
- /**
- * Inject a dependency injection container (optional)
- *
- * @param mixed $dic The container
- * @access public
- * @return void
- */
- public function setContainer( $dic )
- {
- $this->dic = $dic;
- }
+ /**
+ * Inject a dependency injection container (optional)
+ *
+ * @param mixed $dic The container
+ * @access public
+ * @return void
+ */
+ public function setContainer($dic)
+ {
+ $this->dic = $dic;
+ }
- /**
- * Inject a cache client interface to interact with a custom cache service
- *
- * @param CacheClientInterface $client The client object or service
- * @access public
- * @return void
- */
- public function setClient( CacheClientInterface $client )
- {
- if ( is_object( $client ) && ( $client instanceof CacheClientInterface ) )
- $this->client = $client;
- else
- {
- throw new \Exception( 'Invalid Cache Client Interface' );
- }
- }
+ /**
+ * Inject a cache client interface to interact with a custom cache service
+ *
+ * @param CacheClientInterface $client The client object or service
+ * @access public
+ * @return void
+ */
+ public function setClient(CacheClientInterface $client)
+ {
+ if (is_object($client) && ($client instanceof CacheClientInterface))
+ $this->client = $client;
+ else {
+ throw new \Exception('Invalid Cache Client Interface');
+ }
+ }
- /**
- * Retrieve a value from the cache using the provided key
- *
- * @param string|array $key The unique key or array of keys identifying the data to be retrieved.
- * @access public
- * @return mixed The requested data, or false if there is an error
- */
- public function get( $key )
- {
- if ( $this->isSafe() && !empty( $key ) )
- {
- return $this->client->get( $key );
- }
+ /**
+ * Retrieve a value from the cache using the provided key
+ *
+ * @param string|array $key The unique key or array of keys identifying the data to be retrieved.
+ * @access public
+ * @return mixed The requested data, or false if there is an error
+ */
+ public function get($key)
+ {
+ if ($this->isSafe() && !empty($key)) {
+ return $this->client->get($key);
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Add a key/value to the cache
- *
- * @param string $key A unique key to identify the data you want to store
- * @param string $value The value you want to store in the cache
- * @param int $ttl Optional: Lifetime of the data (default: 300 seconds - five minutes)
- * @access public
- * @return mixed Whatever the CacheClientObject returns, or false.
- */
- public function set( $key, $value, $ttl = 300 )
- {
- if ( $this->isSafe() && !empty( $key ) )
- {
- return $this->client->set( $key, $value, $ttl );
- }
+ /**
+ * Add a key/value to the cache
+ *
+ * @param string $key A unique key to identify the data you want to store
+ * @param string $value The value you want to store in the cache
+ * @param int $ttl Optional: Lifetime of the data (default: 300 seconds - five minutes)
+ * @access public
+ * @return mixed Whatever the CacheClientObject returns, or false.
+ */
+ public function set($key, $value, $ttl = 300)
+ {
+ if ($this->isSafe() && !empty($key)) {
+ return $this->client->set($key, $value, $ttl);
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Delete a key from the cache
- *
- * @param string $key Unique key
- * @access public
- * @return void
- */
- public function delete( $key )
- {
- if ( $this->isSafe() && !empty( $key ) )
- {
- return $this->client->delete( $key );
- }
+ /**
+ * Delete a key from the cache
+ *
+ * @param string $key Unique key
+ * @access public
+ * @return void
+ */
+ public function delete($key)
+ {
+ if ($this->isSafe() && !empty($key)) {
+ return $this->client->delete($key);
+ }
- return false;
- }
+ return false;
+ }
- /**
- * Checks if the cache is in a usable state
- *
- * @access public
- * @return boolean True if the cache is usable, otherwise false
- */
- public function isSafe()
- {
- if ( $this->client instanceof CacheClientInterface )
- {
- return $this->client->isSafe();
- }
+ /**
+ * Checks if the cache is in a usable state
+ *
+ * @access public
+ * @return boolean True if the cache is usable, otherwise false
+ */
+ public function isSafe()
+ {
+ if ($this->client instanceof CacheClientInterface) {
+ return $this->client->isSafe();
+ }
- return $this->safe;
- }
+ return $this->safe;
+ }
}
View
@@ -14,9 +14,33 @@
*/
interface CacheInterface
{
- public function __construct( CacheClientInterface $client = null );
- public function get( $key );
- public function set( $key, $value, $ttl );
- public function delete( $key );
- public function isSafe();
+ /**
+ * @param CacheClientInterface $client
+ */
+ public function __construct(CacheClientInterface $client = null);
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function get($key);
+
+ /**
+ * @param string $key
+ * @param mixed $value
+ * @param int $ttl
+ * @return mixed
+ */
+ public function set($key, $value, $ttl);
+
+ /**
+ * @param string $key
+ * @return mixed
+ */
+ public function delete($key);
+
+ /**
+ * @return bool
+ */
+ public function isSafe();
}
Oops, something went wrong.

0 comments on commit f4a76ab

Please sign in to comment.