/** * @param string $filename Filename containing all domains */ public function __construct($filename) { if (!file_exists($filename)) { throw new \InvalidArgumentException(sprintf('File "%s" not found', $filename)); } $this->domains = Utilities::parseLines(file_get_contents($filename)); }
/** * Check if it's a valid email, ie. not a throwaway email. * * @param string $email The email to check * * @return bool true for a throwaway email */ public function isValid($email) { if (false === ($email = filter_var($email, FILTER_VALIDATE_EMAIL))) { return false; } try { list($local, $domain) = Utilities::parseEmailAddress($email); } catch (InvalidEmailException $e) { return false; } return !$this->adapter->isThrowawayDomain($domain); }
public function testParseLines() { $content = <<<TEXT # This is a comment and should be parsed Uppercase foo bar #baz TEXT; $parsedContent = Utilities::parseLines($content); $expectedLines = array('uppercase', 'foo', 'bar'); $diffs = array_diff($expectedLines, $parsedContent); $message = <<<MSG Failed asserting that parsed content equals expected lines. Expected: %s Actual: %s MSG; $this->assertEmpty($diffs, sprintf($message, print_r($expectedLines, true), print_r($parsedContent, true))); }
/** * @param File $file */ public function __construct(File $file) { $this->domains = Utilities::parseLines($file->getContent()); }