Ejemplo n.º 1
0
 /**
  * @param string $serializedString
  *
  * @return tubepress_api_contrib_ContributableInterface[]
  *
  * @throws InvalidArgumentException
  */
 public function unserialize($serializedString)
 {
     $decoded = $serializedString;
     $encoding = $this->_bootSettings->getSerializationEncoding();
     switch ($encoding) {
         /** @noinspection PhpMissingBreakStatementInspection */
         case 'gzip-then-base64':
         case 'base64':
             $decoded = @base64_decode($serializedString);
             if ($decoded === false) {
                 throw new InvalidArgumentException('Failed to base64_decode() serialized data');
             }
             if ($encoding === 'gzip-then-base64') {
                 $decoded = gzuncompress($decoded);
                 if ($decoded === false) {
                     throw new InvalidArgumentException('Failed to gzuncompress() serialized data');
                 }
             }
             break;
         case 'urlencode':
             $decoded = urldecode($serializedString);
             break;
         default:
             break;
     }
     $unserialized = @unserialize($decoded);
     if ($unserialized === false) {
         throw new InvalidArgumentException('Failed to unserialize incoming data');
     }
     return $unserialized;
 }