Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function getData($key)
 {
     if (!($sqlDriver = $this->getSqliteDriver($key))) {
         return false;
     }
     $sqlKey = $this->makeSqlKey($key);
     if (!($data = $sqlDriver->get($sqlKey))) {
         return false;
     }
     $data['data'] = Utilities::decode($data['data'], $data['encoding']);
     return $data;
 }
 public function testDecode()
 {
     $this->assertTrue(Utilities::decode(Utilities::encode(true), Utilities::encoding(true)), 'decode unpacked boolean \'true\'.');
     $this->assertFalse(Utilities::decode(Utilities::encode(false), Utilities::encoding(false)), 'decode unpacked boolean \'false\'');
     $string = 'String of doom!';
     $this->assertEquals(Utilities::decode(Utilities::encode($string), Utilities::encoding($string)), $string, 'decode unpacked string');
     $this->assertEquals(Utilities::decode(Utilities::encode(234), Utilities::encoding(234)), 234, 'Sdecode unpacked integer');
     $this->assertEquals(Utilities::decode(Utilities::encode(1.432), Utilities::encoding(1.432)), 1.432, 'decode unpacked float');
     $std = new \stdClass();
     $this->assertEquals(Utilities::decode(Utilities::encode($std), Utilities::encoding($std)), $std, 'decode unpacked object');
     $array = array(4, 5, 7);
     $this->assertEquals(Utilities::decode(Utilities::encode($array), Utilities::encoding($array)), $array, 'decode unpacked array');
 }