public function testGetHashString()
 {
     $hash = new HashContainer();
     $hash->setHashString('033bd94b1168d7e4f0d644c3c95e35bf');
     $this->assertInstanceOf('\\SimpleHash\\Container\\HashContainer', $hash);
     $this->assertEquals('033bd94b1168d7e4f0d644c3c95e35bf', $hash->getHashString());
 }
Example #2
0
 /**
  * Magic factory method
  *
  * @param   string      $name
  * @param   array       $arguments
  * @throws  SimpleHashException
  */
 public function __call($name, $arguments)
 {
     if ($this->isCalledGetter($name) === false) {
         throw SimpleHashException::make('Unsupported method "' . $name . '" called!');
     }
     // Initialize variables
     $plainText = $this->getPlainStringFromArguments($arguments);
     // Initialize calculator
     $calculatorClass = $this->getCalculatorName($name);
     if (!$this->calculatorExists($calculatorClass)) {
         throw SimpleHashException::make('No calclator "' . $calculatorClass . '" exists!');
     }
     $calculator = $this->initializeCalculator($calculatorClass);
     // Initialize hash container with hash string
     $container = new HashContainer();
     $container->setHashString($calculator->getHash($plainText));
     // Return hash container
     return $container;
 }