john-kariuki/urban-words

Urban words, CheckpointOne Andela

1.0.0 2016-01-23 23:36 UTC

This package is not auto-updated.

Last update: 2024-06-04 20:42:59 UTC


README

![Build Pass] (https://travis-ci.org/andela-jkariuki/CheckpointOne.svg?branch=master) Scrutinizer Code Quality Coverage Status

Urban Dictionary Agnostic PHP Package

Andela Checkpoint One.

Urban Words Manager

An urban words dictionary, Urban Word CRUD and Ranking System for word occurence in a sentence.

Word Rank Manager

Rank the occurence of words in a sentence.

#TIA

Installation

add the package to your projects folder

composer require john-kariuki/urban-words

Install packages using composer

composer install

Usage

Let's get using Urban Words

<?php
require 'vendor/autoload.php';

use John\Cp\UrbanWordsDatastore;
use John\Cp\UrbanWordsManager;
use John\Cp\WordRankManager;
use John\Exceptions\UrbanWordException;
use John\Exceptions\WordRankManagerException;
use John\Exceptions\WordManagerException;

//Class UrbanWordsDatastore contains a static array of urban words
print_r(UrbanWordsDatastore::$data);

/**
    * Class UrbanWordsManager performs CRUD methods on the $data array in UrbanWordsDataStore
    * Methods:
    * addWord(word, desc, sentence)
    * readWord(word)
    * updateWord(word, foo, bar, foobar)
    * deleteWord(word)
*/
try {

    $urbanWord = new UrbanWordsManager();

    //Add new word, description and sentence
    print_r($urbanWord->addWord('Bae', 'Endearing term for lover', 'Your bae has a bae'));

    //Pass slang word to read
    print_r($urbanWord->readWord('Bae'));

    //Update slang word details
    print_r($urbanWord->updateWord("Bae", "Foo", "Bar", "Foo Bar"));

    //Pass slang word to delete
    print_r($urbanWord->deleteWord('Turnt'));

    print_r($urbanWord->getWords());

} catch (WordManagerException $e) {
    echo $e->errorMessage();
}

//Class WordRankManager returns the frequency of occurence of a word in a sentence


try {
    $sentence = new WordRankManager("The big brown fox is just a big brown fox jumping up all in the lazy dog's business");
    print_r($sentence->ranker());
} catch (WordRankManagerException $e) {
    echo $e->errorMessage();
}

Contributing

Contributions are welcome and will be fully credited.

We accept contributions via Pull Requests on Github.

Pull Requests

  • PSR-2 Coding Standard - The easiest way to apply the conventions is to install PHP Code Sniffer.

  • Add tests! - Your patch won't be accepted if it doesn't have tests.

  • Document any change in behaviour - Make sure the README.md and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

  • Create feature branches - Don't ask us to pull from your master branch.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

  • Send coherent history - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

Security

If you discover any security related issues, please email me at John Kariuki or create an issue.

Credits

John kariuki

License

The MIT License (MIT)

Copyright (c) 2016 John kariuki john.kariuki@andela.com

This is open-sourced software licensed under the MIT license.