PHP Class Pantheon\Terminus\DataStore\FileStore

Inheritance: implements Pantheon\Terminus\DataStore\DataStoreInterface
Show file Open project: pantheon-systems/terminus

Protected Properties

Property Type Description
$directory The directory to store the data files in.

Public Methods

Method Description
__construct ( $directory )
get ( string $key ) : mixed Reads retrieves data from the store
has ( string $key ) : boolean Checks if a key is in the store
keys ( ) : array Return a list of all keys in the store.
remove ( string $key ) Remove value from the store
set ( string $key, mixed $data ) Saves a value with the given key

Protected Methods

Method Description
cleanKey ( $key ) : mixed Make the file path safe by whitelisting characters.
getFileName ( string $key ) : string Get a valid file name for the given key.

Method Details

__construct() public method

public __construct ( $directory )

cleanKey() protected method

This is a very naive approach to hashing but in practice this doesn't matter since this is only used for a few already safe keys.
protected cleanKey ( $key ) : mixed
$key
return mixed

get() public method

Reads retrieves data from the store
public get ( string $key ) : mixed
$key string A key
return mixed The value fpr the given key or null.

getFileName() protected method

Get a valid file name for the given key.
protected getFileName ( string $key ) : string
$key string The data key to be written or read
return string A file path

has() public method

Checks if a key is in the store
public has ( string $key ) : boolean
$key string A key
return boolean Whether a value exists with the given key

keys() public method

Return a list of all keys in the store.
public keys ( ) : array
return array A list of keys

remove() public method

Remove value from the store
public remove ( string $key )
$key string A key

set() public method

Saves a value with the given key
public set ( string $key, mixed $data )
$key string A key
$data mixed Data to save to the store

Property Details

$directory protected property

The directory to store the data files in.
protected $directory