phpvms/app/Repositories/KvpRepository.php
Nabeel S e12188b7d3
Issue/327 versioning (#345)
* Switch to semver format

* Rewrite new version check to use Github Releases and cron

* Styling

* Remove v from in front of version

* New version check test fix

* Uncomment test case
2019-08-06 17:48:00 -04:00

70 lines
1.3 KiB
PHP

<?php
namespace App\Repositories;
use Spatie\Valuestore\Valuestore;
class KvpRepository
{
private $valueStore;
public function __construct()
{
$this->valueStore = Valuestore::make(config('phpvms.kvp_storage_path'));
}
/**
* @param $key
* @param null $default
*
* @return array|string|null
*/
public function retrieve($key, $default = null)
{
return $this->get($key, $default);
}
/**
* Get a value from the KVP store
*
* @param string $key
* @param mixed $default default value to return
*
* @return array|string|null
*/
public function get($key, $default = null)
{
if (!$this->valueStore->has($key)) {
return $default;
}
return $this->valueStore->get($key);
}
/**
* @alias store($key,$value)
*
* @param string $key
* @param mixed $value
*
* @return null
*/
public function save($key, $value)
{
return $this->store($key, $value);
}
/**
* Save a value to the KVP store
*
* @param $key
* @param $value
*
* @return null
*/
public function store($key, $value)
{
return $this->valueStore->put($key, $value);
}
}