gavinggordon / wordstore
This is a CRUD compliant, language data storage class.
Requires (Dev)
- phpunit/phpunit: 4.0.*
This package is not auto-updated.
Last update: 2024-12-19 01:23:23 UTC
README
Synopsis
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.
How to use 'WordStore'
Install via Composer...
composer require gavinggordon/wordstore
Include autoload.php...
include_once( __DIR__ . '/vendor/autoload.php' );
Create new instance...
//
// 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
Adding a word...
//
// 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'
] );
Finding a word...
//
// 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
// );
//
Updating a word...
//
// 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
// )
// );
//
Deleting a word...
//
// 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
//
More Information
PHP Innovation Award
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.