Decode data

@param  string  $data
@param  boolean $assoc
@return mixed
182843
static public function decode($data, $assoc=false)
	{
	    if (is_array($data) && $assoc === true) {
	        return $data;
	    }
	    if (!is_string($data)) {
	        $data = json_encode($data);
	    }
	    return json_decode($data, $assoc);
	}
875368
public function getKey($field, $assoc = false)
    {
        return $assoc ? $this->get($assoc)[$field] : $this->get($assoc)->{$field};
    }
278648
public function decode($data)
    {
        $result = [];
        $offset = 0;
        $length = strlen($data);
        while ($offset < $length)
        {
            if (!strstr(substr($data, $offset), '|'))
            {
                return [];
            }
            $pos = strpos($data, '|', $offset);
            $num = $pos - $offset;
            $varname = substr($data, $offset, $num);
            $offset += $num + 1;
            $dataItem = unserialize(substr($data, $offset));
            $result[$varname] = $dataItem;
            $offset += strlen(serialize($dataItem));
        }
        return $result;
    }
871890
private function decodeJson($input, $assoc = false)
    {
        $input = trim($input);

        return json_decode($input, $assoc);
    }
969358
private static function decodeArray($string, $assoc)
    {
        // Start empty.
        $arr = array();
        $size = 0;
        $offset = 1;

        // Get some information on the first byte.
        list($firstHex, $firstOctal) = self::analyzeFirstChar($string[0]);

        if ($firstOctal === '9') {
            // fixarray 1000xxxx
            $size   = hexdec(substr($firstHex, 1));
            $offset = 1;
        } elseif ($firstHex === 'dc') {
            // arrar 16
            $size   = hexdec(unpack('H*', substr($string, 1, 2)));
            $offset = 3;
        } elseif ($firstHex === 'dd') {
            // array 32
            $size = hexdec(unpack('H*', substr($string, 1, 4)));
            $offset = 5;
        }

        // Shorten the string.
        $string = substr($string, $offset);

        // Loop to decode every item of the array.
        for ($i = 0; $i < $size; $i++) {
            list($item, $string) = self::decodeRecursive($string, $assoc);
            $arr[] = $item;
        }

        // Return the decoded data and the resulting string.
        return array($arr, $string);
    }
519597
public function decode($data)
    {
        $parser = new Parser();
        $this->arrayData = (array) $parser->parse($data);
        return $this->arrayData;
    }
1077849
public function decode($data)
    {
        $data = \preg_replace('/[^0-9A-Fa-f]/', '', \rtrim($data, '>'));
        if ((\strlen($data) % 2) === 1) {
            $data .= '0';
        }

        return \pack('H*', $data);
    }
266536
function decode(string $data) {
        try {
            $msg = $this->etf->decode($data);
            if($msg === '' || $msg === null) {
                throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The ETF decoder was unable to decode the data');
            }
        } catch (\CharlotteDunois\Kimberly\Exception $e) {
            throw new \CharlotteDunois\Yasmin\WebSocket\DiscordGatewayException('The ETF decoder was unable to decode the data', 0, $e);
        }
        
        $obj = $this->convertIDs($msg);
        return $obj;
    }
1209306
public function decode($data, $format, array $context = array())
    {
        $value = Encoder::decode($data, Encoder::TYPE_ARRAY);

        return $value;
    }
876003
public function getJsonResponse($assoc = true)
    {
        //argument 1 must be a boolean
        Argument::i()->test(1, 'bool');

        $this->meta['response'] = $this->getResponse();
        return json_decode($this->meta['response'], $assoc);
    }
475839
public function getData($json = true, $assoc = false)
    {
        $data = file_get_contents('php://input');
        if (!$json) {
            return $data;
        }
        return json_decode($data, $assoc);
    }
1357166
private function decodeNonUtf8FromUtf8(array $data)
    {
        $encodedKeys = [];
        if (isset($data[$this->encodingAnnotation])) {
            $encodedKeys = $data[$this->encodingAnnotation];
            unset($data[$this->encodingAnnotation]);
        }

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

            if (isset($encodedKeys[$key])) {
                $originalKey = $key;
                if ($encodedKeys[$key] & static::KEY_UTF8ENCODED) {
                    $key = mb_convert_encoding($key, '8bit', 'UTF-8');
                }
                if ($encodedKeys[$originalKey] & static::VALUE_UTF8ENCODED) {
                    $value = mb_convert_encoding($value, '8bit', 'UTF-8');
                }
            }

            $decodedData[$key] = $value;
        }

        return $decodedData;
    }
440055
public function decodeArray($string, $fieldName = 'Unknown', $assoc = false)
    {
        if (empty($string)) {
            return [];
        }
        $array = self::decode(!empty($string) ? $string : '[]', $fieldName, $assoc);
        if (!$array || !is_array($array)) {
            throw new \Exception('The field '.$fieldName.' is not a JSON array as expected.');
        }

        return $array;
    }
887600
public static function decode($json, $assoc = false, $options = 0)
    {
        if (!is_string($json)) {
            throw new \InvalidArgumentException('Argument json is not a string');
        }
        $result = json_decode($json, (bool) $assoc, 512, (int) $options);
        if ($result === null) {
            throw new \RuntimeException(static::$errorMessages[json_last_error()]);
        }

        return $result;
    }
390852
public function read(bool $assoc = false)
    {
        $json = json_decode(parent::read(), $assoc);
        if (json_last_error() !== JSON_ERROR_NONE) {
            throw new RuntimeException('Invalid json file');
        }
        return $json;
    }
1046282
public function decodeData($data)
    {
        $output = array();
        while (strlen($data) > 0) {
            preg_match('/(\w+)(\[(\d+)\])?=/', $data, $matches);
            $key = $matches[1];
            $data = substr($data, strlen($matches[0]));

            if (isset($matches[3])) {
                $value = substr($data, 0, $matches[3]);
            } else {
                $next = strpos($data, '&');
                $value = $next === false ? $data : substr($data, 0, $next);
            }

            $data = substr($data, strlen($value) + 1);
            $output[$key] = $value;
        }

        return $output;
    }
1199564
public function decodeJson($assoc = false){

        foreach(self::$jsonable as $key){

            if(isset($this->{$key}) && Utils::isJson($$this->{$key})){
                $this->{$key} = json_decode($this->{$key}, $assoc);
            }
        }

        return $this;
    }