/** * Testing the isEncodable method */ public function testIsEncodable() { $array = $this->getDummyHmacData(); $this->assertFalse($this->entity->isEncodable()); $this->entity->setData($array['data']); $this->entity->setKey($array['key']); $this->entity->setTime($array['time']); $this->assertTrue($this->entity->isEncodable()); }
/** * Encodes the HMAC based on the values that have been entered using the hash() function * * @throws HmacInvalidArgumentException * @return AbstractAdapter */ public function encode() { if (!$this->entity->isEncodable()) { throw new HmacInvalidArgumentException('The item is not encodable, make sure the key, time and data are set'); } $firstHash = $this->hash($this->entity->getData(), $this->entity->getTime(), $this->noFirstHashIterations); $secondHash = $this->hash($this->entity->getKey(), '', $this->noSecondHashIterations); $this->entity->setHmac($this->hash($firstHash, $secondHash, $this->noFinalHashIterations)); return $this; }