e12188b7d3
* 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
70 lines
1.3 KiB
PHP
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);
|
|
}
|
|
}
|