Esempio n. 1
0
 /**
  * Facade interface method
  *
  * @param   string      $name
  * @param   array       $arguments
  * @return  \SimpleHash\Container\HashContainer
  * @throws  \SimpleHash\Exception\SimpleHashException
  */
 public static function __callStatic($name, $arguments)
 {
     $factory = new HashFactory(self::getCalclatorParams($arguments));
     // Check if the requested algorithm is implemented
     if (!$factory->hasCalculator($name)) {
         throw SimpleHashException::make('Algorithm "' . $name . '" is not implemented yet!');
     }
     // Build hash container
     $getterMethod = self::getFactoryMethodName($name);
     return $factory->{$getterMethod}(self::getPlainTextString($arguments));
 }
Esempio n. 2
0
 public function testHasCalculator()
 {
     $hashFactory = new HashFactory();
     $this->assertTrue($hashFactory->hasCalculator('Md5'));
     $this->assertFalse($hashFactory->hasCalculator('Test'));
 }