public function testDecode() { $this->assertTrue(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode(true), ehough_stash_Utilities::encoding(true)), 'decode unpacked boolean \'true\'.'); $this->assertFalse(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode(false), ehough_stash_Utilities::encoding(false)), 'decode unpacked boolean \'false\''); $string = 'String of doom!'; $this->assertEquals(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode($string), ehough_stash_Utilities::encoding($string)), $string, 'decode unpacked string'); $this->assertEquals(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode(234), ehough_stash_Utilities::encoding(234)), 234, 'Sdecode unpacked integer'); $this->assertEquals(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode(1.432), ehough_stash_Utilities::encoding(1.432)), 1.432, 'decode unpacked float'); $std = new stdClass(); $this->assertEquals(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode($std), ehough_stash_Utilities::encoding($std)), $std, 'decode unpacked object'); $array = array(4, 5, 7); $this->assertEquals(ehough_stash_Utilities::decode(ehough_stash_Utilities::encode($array), ehough_stash_Utilities::encoding($array)), $array, 'decode unpacked array'); }
/** * @param array $key * @param array $data * @param int $expiration * @return bool */ public function storeData($key, $data, $expiration) { if (!($sqlDriver = $this->getSqliteDriver($key))) { return false; } $storeData = array('data' => ehough_stash_Utilities::encode($data), 'expiration' => $expiration, 'encoding' => ehough_stash_Utilities::encoding($data)); return $sqlDriver->set($this->makeSqlKey($key), $storeData, $expiration); }