public function decode($data)
    {
        $decodedData = json_decode($data, true);

        // fallback for old storage that uses PHP serialize format
        if (is_null($decodedData) && $data) {
            $decodedData = unserialize($data);
        }

        if (is_array($decodedData)) {
            if (isset($decodedData[self::STORAGE_KEY_FORMAT])) {
                if ($decodedData[self::STORAGE_KEY_FORMAT] != $this->getFormat()) {
                    \common_Logger::w(sprintf('QtiTimeStorage: wrong decoder applied! (Expected: %s, Applied: %s)', $decodedData[self::STORAGE_KEY_FORMAT], $this->getFormat()));
                }

                foreach ($decodedData as $key => &$value) {
                    if (is_array($value)) {
                        $decodedData[$key] = $this->unpackTimeLine($value);
                    }
                }

                unset($decodedData[self::STORAGE_KEY_FORMAT]);
                unset($decodedData[self::STORAGE_KEY_VERSION]);
            } else {
                foreach ($decodedData as $key => &$value) {
                    if (is_array($value)) {
                        $timeLine = new QtiTimeLine();
                        $timeLine->fromArray($value);
                        $decodedData[$key] = $timeLine;
                    }
                }
            }
        }

        return $decodedData;
    }
public function decode($data)
    {
        $decodedData = json_decode($data, true);

        
        if (is_null($decodedData) && $data) {
            $decodedData = unserialize($data);
        }

        if (is_array($decodedData)) {
            if (isset($decodedData[self::STORAGE_KEY_FORMAT])) {
                if ($decodedData[self::STORAGE_KEY_FORMAT] != $this->getFormat()) {
                    \common_Logger::w(sprintf('QtiTimeStorage: wrong decoder applied! (Expected: %s, Applied: %s)', $decodedData[self::STORAGE_KEY_FORMAT], $this->getFormat()));
                }

                foreach ($decodedData as $key => &$value) {
                    if (is_array($value)) {
                        $decodedData[$key] = $this->unpackTimeLine($value);
                    }
                }

                unset($decodedData[self::STORAGE_KEY_FORMAT]);
                unset($decodedData[self::STORAGE_KEY_VERSION]);
            } else {
                foreach ($decodedData as $key => &$value) {
                    if (is_array($value)) {
                        $timeLine = new QtiTimeLine();
                        $timeLine->fromArray($value);
                        $decodedData[$key] = $timeLine;
                    }
                }
            }
        }

        return $decodedData;
    }
public function decode ( $ data ) { $ decodedData = json_decode ( $ data , true ) ; // fallback for old storage that uses PHP serialize format if ( is_null ( $ decodedData ) && $ data ) { $ decodedData = unserialize ( $ data ) ; } if ( is_array ( $ decodedData ) ) { if ( isset ( $ decodedData [ self :: STORAGE_KEY_FORMAT ] ) ) { if ( $ decodedData [ self :: STORAGE_KEY_FORMAT ] != $ this -> getFormat ( ) ) { \ common_Logger :: w ( sprintf ( 'QtiTimeStorage: wrong decoder applied! (Expected: %s, Applied: %s)' , $ decodedData [ self :: STORAGE_KEY_FORMAT ] , $ this -> getFormat ( ) ) ) ; } foreach ( $ decodedData as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ decodedData [ $ key ] = $ this -> unpackTimeLine ( $ value ) ; } } unset ( $ decodedData [ self :: STORAGE_KEY_FORMAT ] ) ; unset ( $ decodedData [ self :: STORAGE_KEY_VERSION ] ) ; } else { foreach ( $ decodedData as $ key => & $ value ) { if ( is_array ( $ value ) ) { $ timeLine = new QtiTimeLine ( ) ; $ timeLine -> fromArray ( $ value ) ; $ decodedData [ $ key ] = $ timeLine ; } } } } return $ decodedData ; }
Decode a string encoded with the managed format.
@param string $data
@return mixed
Decode a string encoded with the managed format .