Skip to content

Clean-up and bug fixes #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions src/Torann/Registry/Cache.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php namespace Torann\Registry;
<?php
namespace Torann\Registry;

class Cache {
class Cache
{

/**
* Timestamp key.
Expand Down Expand Up @@ -33,12 +35,12 @@ class Cache {
/**
* Create a new instance.
*
* @param string $cachePath
* @param string $timestampManager
* @param string $cachePath
* @param string $timestampManager
*/
public function __construct($cachePath, $timestampManager)
{
$this->path = $cachePath.DIRECTORY_SEPARATOR.'torann_registry.json';
$this->path = $cachePath . DIRECTORY_SEPARATOR . 'torann_registry.json';

// Instantiate timestamp manager
if (class_exists($timestampManager)) {
Expand All @@ -54,19 +56,19 @@ public function __construct($cachePath, $timestampManager)
/**
* Get a all cached values.
*
* @param mixed $default
* @param mixed $default
* @return mixed
*/
public function all($default = array())
{
return (! empty($this->entries) ) ? $this->entries : $default;
return (!empty($this->entries)) ? $this->entries : $default;
}

/**
* Get a key's value from the cache.
*
* @param string $key
* @param mixed $default
* @param string $key
* @param mixed $default
* @return mixed
*/
public function get($key = null, $default = null)
Expand All @@ -77,8 +79,8 @@ public function get($key = null, $default = null)
/**
* Add a key's value to the cache.
*
* @param string $key
* @param string $value
* @param string $key
* @param string $value
* @return bool
*/
public function add($key, $value)
Expand All @@ -91,7 +93,7 @@ public function add($key, $value)
/**
* Set value to the cache.
*
* @param array $value
* @param array $value
* @return bool
*/
public function set(array $value)
Expand All @@ -104,7 +106,7 @@ public function set(array $value)
/**
* Remove a key from cache.
*
* @param string $key
* @param string $key
* @return bool
*/
public function remove($key)
Expand Down Expand Up @@ -174,6 +176,6 @@ public function save()
$this->timestampManager->update($updated);
}

return (bool) file_put_contents($this->path, json_encode($this->entries));
return (bool)file_put_contents($this->path, json_encode($this->entries));
}
}
22 changes: 13 additions & 9 deletions src/Torann/Registry/Facades/Registry.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
<?php namespace Torann\Registry\Facades;
<?php
namespace Torann\Registry\Facades;

use Illuminate\Support\Facades\Facade;

class Registry extends Facade {

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor() { return 'registry'; }
class Registry extends Facade
{

/**
* Get the registered name of the component.
*
* @return string
*/
protected static function getFacadeAccessor()
{
return 'registry';
}
}
Loading