From 5f2eaead1019c36c04c699e106bd6dcb999eb5f6 Mon Sep 17 00:00:00 2001 From: Josh Sherman Date: Tue, 23 Sep 2014 22:19:45 -0400 Subject: [PATCH] Moved Google Profanity API to it's own repo It can be found at https://github.com/joshtronic/php-googleprofanity --- src/classes/API/Google/Profanity.php | 48 ---------------------- tests/classes/API/Google/ProfanityTest.php | 41 ------------------ 2 files changed, 89 deletions(-) delete mode 100644 src/classes/API/Google/Profanity.php delete mode 100644 tests/classes/API/Google/ProfanityTest.php diff --git a/src/classes/API/Google/Profanity.php b/src/classes/API/Google/Profanity.php deleted file mode 100644 index 1126168..0000000 --- a/src/classes/API/Google/Profanity.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright Copyright 2007-2014, Josh Sherman - * @license http://www.opensource.org/licenses/mit-license.html - * @package PICKLES - * @link https://github.com/joshtronic/pickles - */ - -/** - * Google Profanity API Interface - */ -class API_Google_Profanity -{ - /** - * Check - * - * Checks if a word is considered profanity. - * - * @usage API_Google_Profanity::check('fuck'); // returns true - * @param string $word word to check - * @param string $endpoint the endpoint to call (helps testing) - * @return boolean whether or not the word is profanity - */ - public static function check($word, $endpoint = 'http://www.wdyl.com/profanity?q=') - { - $response = json_decode(file_get_contents($endpoint . $word), true); - - if ($response == null || !isset($response['response']) - || !in_array($response['response'], ['true', 'false'])) - { - throw new Exception('Invalid response from API.'); - } - else - { - return $response['response'] == 'true'; - } - } -} - diff --git a/tests/classes/API/Google/ProfanityTest.php b/tests/classes/API/Google/ProfanityTest.php deleted file mode 100644 index 612cd92..0000000 --- a/tests/classes/API/Google/ProfanityTest.php +++ /dev/null @@ -1,41 +0,0 @@ -assertEquals($b, API_Google_Profanity::check($a)); - } - - public function providerFormatPhoneNumber() - { - return [ - ['alpha', false], - ['beta', false], - ['joshtronic', false], - ['god', false], - ['fck', false], - ['fuck', true], - ['shit', true], - ['cocksucker', true], - ['cuntface', false], // Unsure why not... - ]; - } - - /** - * @expectedException Exception - * @expectedExceptionMessage Invalid response from API. - */ - public function testInvalidResponse() - { - $file = SITE_PATH . 'null-'; - - file_put_contents($file . 'test', null); - - API_Google_Profanity::check('test', $file); - } -} -