/** * * @param string $fileName * * @return CacheEntry */ public function readEntry($key) { if (!$this->exists($key)) { return false; } $fileInfos = implode(DIRECTORY_SEPARATOR, array($this->cacheDirectory, md5('cacheKey:' . $key) . '.cache')); $contents = file_get_contents($fileInfos); $entry = $this->serializer->unserialize($contents); if (!$entry instanceof \Fwk\Cache\CacheEntry) { throw new \Fwk\Cache\Exceptions\ReadError("contents is not a valid CacheEntry"); } $entry->setSerializer($this->serializer); return $entry; }
/** * * @param string $fileName * * @return CacheEntry */ public function readEntry($key) { $query = "SELECT * FROM %s WHERE `key` = ? LIMIT 1"; $stmt = $this->pdo->prepare(sprintf($query, $this->options['table.infos'])); $stmt->execute(array($key)); $res = $stmt->fetch(); if (!$res) { throw new \Fwk\Cache\Exceptions\ReadError("invalid CacheEntry key: {$key}"); } $entry = new \Fwk\Cache\CacheEntry(null, $key); $entry->setCreatedOn($res['created_on']); $entry->setKey($res['key']); if (strlen($res['max_age']) > 50) { $maxAge = $this->serializer->unserialize($res['max_age']); } else { $maxAge = $res['max_age']; } $entry->setMaxAge($maxAge); $entry->setSerializer($this->serializer); return $entry; }
/** * @param resource|string $stream * @param mixed $object * @param string $format * @return mixed */ public function unserialize($stream, &$object = null, $format = null) { return $this->serializer->unserialize($stream, $format ?: $this->format, $this->type, $this->options, $object); }
/** * @expectedException \Link0\Profiler\SerializerException * @expectedExceptionMessage Unable to unserialize data: FDSAfoobar */ public function testUnexpectedDataToThrowException() { $this->serializer->unserialize('FDSAfoobar'); }
/** * @param array $serialized */ public function arrayUnserialize(array $serialized) { Serializer::unserialize($this, $serialized); }
/** * @param string $serialized */ public function jsonUnserialize(string $serialized) { Serializer::unserialize($this, json_decode($serialized, true)); }
/** * @param string $serialized */ public function unserialize($serialized) { Serializer::unserialize($this, unserialize($serialized)); }
protected function getVideoDetails() { $unserialized = Serializer::unserialize($this->video->getFeed()); return XMLLoader::loadString($unserialized); }