Ejemplo n.º 1
0
 /**
  * Generate a hash value from the current string using the defined algorithm.
  *
  * @param string $algo Name of the algorithm used for calculation (md5, sha1, ripemd160,...).
  *
  * @throws StringObjectException
  * @return $this
  */
 public function hash($algo = 'sha1')
 {
     $algos = new ArrayObject(hash_algos());
     if (!$algos->inArray($algo)) {
         throw new StringObjectException(StringObjectException::MSG_INVALID_HASH_ALGO, [$algo]);
     }
     $this->val(hash($algo, $this->val()));
     return $this;
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider arraySet1
  */
 public function testSearch2($array)
 {
     $a = new ArrayObject($array);
     $searchResult = $a->inArray('v1');
     $key = in_array('v1', $array);
     $this->assertSame($key, $searchResult);
 }