This PHP class ( GGG\WordStore ) is a CRUD compliant language data storage class. It provides the ability to create a language dictionary. All enteries you create are stored in the WordStore and can contain user-definited parameters, all of which can be: searched and retrieved; updated; and, deleted.
composer require gavinggordon/wordstore
include_once( __DIR__ . '/vendor/autoload.php' );
//
// new WordStore(
//
// @param string $dictionary_file *optional*
// default value = 'dictionary.json'
//
// );
//
// @return object
//
$json_dictionary_file = __DIR__ . '/myDictionary.json';
// optionally, override the default name to be used for the .json
// dictionary file, where all the related word data will be stored
$wordstore = new GGG\WordStore( $json_dictionary_file );
// creates the dictionary storage file, if it doesn't already exist
//
// WordStore->add(
//
// @param string $part_of_speech *required*
// possible values =
// 'adjective' || 'adverb' || 'article' || 'interjection' ||
// 'noun' || 'pronoun' || 'personalpronoun' ||
// 'preposition' || 'punctuation' || 'verb'
//
// @param string $word *required*
// possible values = *
//
// @param array $params *required*
// possible values = *
//
// );
//
// @return object | FALSE
//
$wordstore->add( 'noun', 'vuča', [
'translation' => 'friend',
'pronounciation' => 'voo-cha'
] );
//
// WordStore->find(
//
// @param string $value *required*
// possible values = *
//
// @param string $part_of_speech *optional*
// default value = NULL
// possible values =
// 'adjective' || 'adverb' || 'article' || 'interjection' ||
// 'noun' || 'pronoun' || 'personalpronoun' ||
// 'preposition' || 'punctuation' || 'verb'
//
// @param string $param *optional*
// default value = NULL
// possible values = *
//
// );
//
// @return array | FALSE;
//
$word = $wordstore->find( 'vuča' );
print_r( $word );
//
// Array
// (
// [translation] => friend
// [pronounciation] => voo-cha
// );
//
//
// WordStore->update(
//
// @param string $newvalue *required*
// possible values = *
//
// @param string $oldvalue *required*
// possible values = *
//
// @param string $part_of_speech *optional*
// default value = NULL
// possible values =
// 'adjective' || 'adverb' || 'article' || 'interjection' ||
// 'noun' || 'pronoun' || 'personalpronoun' ||
// 'preposition' || 'punctuation' || 'verb'
//
// @param string $param *optional*
// default value = NULL
// possible values = *
//
// );
//
// @return object | FALSE
//
$wordstore->update( 'partner', 'vuča', 'noun', 'translation' );
$word = $wordstore->find( 'buddy' );
//
// Array
// (
// [0] => stdClass Object
// (
// [translation] => partner
// [pronounciation] => voo-cha
// )
// );
//
//
// WordStore->delete(
//
// @param string $newvalue *required*
// possible values = *
//
// @param string $part_of_speech *optional*
// default value = NULL
// possible values =
// 'adjective' || 'adverb' || 'article' || 'interjection' ||
// 'noun' || 'pronoun' || 'personalpronoun' ||
// 'preposition' || 'punctuation' || 'verb'
//
// );
//
// @return object | FALSE
//
$wordstore->delete( 'vuča', 'noun' );
$word = $wordstore->find( 'vuča' );
//
// FALSE
//
This class has been nominated for a PHP Innovation Award, provided by PHPClasses.org. If you found this class to be at all interesting, helpful, particularly useful, or innovative in any way, please vote for it, to show your support for this or any other PHP classes accessible online via my GitHub profile or PHPClasses.org profile.