/**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['error' => null, 'hash' => null, 'settings' => null], $values);
     $message->setError($values['error']);
     $message->setHash($values['hash']);
     $message->setSettings($values['settings']);
     return $message;
 }
 /**
  * {@inheritdoc}
  */
 public static function fromArray(array $values)
 {
     $message = new self();
     $values = array_merge(['hash' => null], $values);
     $message->setHash($values['hash']);
     return $message;
 }
Example #3
0
 /**
  * Creates an instance with data
  *
  * @param  array    $data
  * @return Resource
  */
 public static function create(array $data = array())
 {
     $defaults = array('id' => null, 'uuid' => null, 'hash' => null, 'date_created' => new DateTime(), 'data' => new IdentifiableDataContainer(array()), 'mimetype' => null, 'size' => null, 'exclusive' => false);
     $data = array_merge($defaults, $data);
     $obj = new self();
     $obj->setUuid($data['uuid']);
     $obj->setId($data['id']);
     $obj->setHash($data['hash']);
     $obj->setDateCreated($data['date_created']);
     $obj->setData($data['data']);
     $obj->setMimetype($data['mimetype']);
     $obj->setSize($data['size']);
     $obj->setExclusive($data['exclusive']);
     return $obj;
 }
Example #4
0
 /**
  * Hashes an object using salt provided
  *
  * @param   string  $object hash an object
  * @param   string  $salt   Salt to be used with object
  * @param   integer $rounds The number of rounds to hash it by
  * @param   string  $algo   Algorythm to use when hashing
  * @return  StdClass
  */
 public static function hash($object, $salt = null, $rounds = 0, $algo = null)
 {
     $ret = new self();
     $ret->setSalt($salt)->setRounds($rounds);
     // First mix password and salt
     $data = serialize($object) . $salt;
     if (!is_null($algo)) {
         $ret->setAlgo($algo);
     }
     for ($i = 0; $i <= $ret->getRounds(); $i++) {
         $data = hash($ret->getAlgo(), $data);
     }
     $ret->setHash($data);
     return $ret;
 }