* Determine how buzzwordy a given input is. * * Write a PHP program that given some text will count the number of buzzwords that appear in it, based on this list * of buzzwords from Wikipedia expressed as a percentage of the total number of words in the text. It is important * to know how buzzwordy text is, and your program will be a boon to readers everywhere. Extra credit if your buzzword * meter can take a URL and return the buzzword metric. * * Usage: php buzzwords.php * * @author Jon Wurtzler <*****@*****.**> * @date 01/31/2016 */ use Buzzwords\BuzzwordReader; require_once __DIR__ . '/vendor/autoload.php'; $buzzwords = []; $buzzwordReader = new BuzzwordReader(); // parse command options $shortOpts = "h"; $longOpts = ["file::", "url::"]; $options = getopt($shortOpts, $longOpts); // Read from file if (isset($options['file'])) { $file = "testfile.txt"; // Default state. if ($options['file']) { $file = $options['file']; } $buzzwords = $buzzwordReader->readFileContent($file); } elseif (isset($options['url'])) { $url = "https://nerdery.com"; // Default state.
/** * Test Url Content reader. * * @return void */ public function testUrlReader() { $reader = new BuzzwordReader(); $words = $reader->readUrlContent("https://nerdery.com"); $this->assertCount(3, $words); }