$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. if ($options['url']) { $url = $options['url']; } $buzzwords = $buzzwordReader->readUrlContent($url); } else { $buzzwordText = (string) isset($argv[1]) ? $argv[1] : false; if ($buzzwordText) { $buzzwords = $buzzwordReader->readTextContent($buzzwordText); } } $help = (bool) isset($options['h']) ? true : false; if ($help || count($buzzwords) < 1) { echo <<<HELP Usage: \$ php buzzwords.php <text> \$ php buzzwords.php --file[=<file>] \$ php buzzwords.php --url[=<url>] -h Help
/** * Test Url Content reader. * * @return void */ public function testUrlReader() { $reader = new BuzzwordReader(); $words = $reader->readUrlContent("https://nerdery.com"); $this->assertCount(3, $words); }