Exemple #1
0
 /**
  * Tests explicit casting to string, getting hashes.
  *
  *
  * @covers ::__construct
  * @covers ::setEmail
  * @covers ::toString
  *
  * @depends testToString
  * @dataProvider validHashesProvider
  *
  * @return string
  */
 public function testToStringCustomized($email, $hash)
 {
     // TODO: Implement formating and remove this line:
     $this->markTestIncomplete('This test is for a feature still in development, and has not been implemented yet.');
     $formats = [['format' => '{hash}.php', 'data' => null, 'expected' => $hash . '.php'], ['format' => '{hash}.json', 'data' => ['hash' => 'Not allowed hash placeholder replacement'], 'expected' => $hash . '.json'], ['format' => '{email} ({hash})', 'data' => ['hash' => 'Not allowed hash placeholder replacement', 'email' => 'And not allowed email replacement.'], 'expected' => $email . ' (' . $hash . ')'], ['format' => '{hash} -> {img}', 'data' => ['img' => 'Image'], 'expected' => $hash . ' -> Image']];
     $obj = new Hash($email);
     foreach ($formats as $args) {
         $expected = $args['expected'];
         $actual = $obj->toString($args['format'], $args['data']);
         $this->assertEquals($expected, $actual);
     }
 }
Exemple #2
0
 /**
  * Gets the hash string for the email provided.
  *
  * @param string $email  E-mail.
  * @param string $format Output format.
  * @param array  $data   Extra data for output.
  *
  * @return string Hash MD5 for the email provided.
  */
 public static function get($email, $format = null, array $data = null)
 {
     $hash = new Hash($email);
     return $hash->toString($format, $data);
 }