예제 #1
0
 /**
  * @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));
 }
예제 #2
0
 /**
  * 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);
 }
예제 #3
0
    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)));
    }
예제 #4
0
 /**
  * @param File $file
  */
 public function __construct(File $file)
 {
     $this->domains = Utilities::parseLines($file->getContent());
 }