Returns the response data or throws an Exception if it was unsuccessful
@param  string $raw The data from the response
@return array
336250
protected function handleResponse($raw){
        $data = json_decode($raw,true);

        if(!isset($data['status_code'])){
            return $raw;
        }

        if($data['status_code']>=300 || $data['status_code']<200){
            switch ($data['status_txt']) {
                case 'RATE_LIMIT_EXCEEDED':
                    throw new BitlyRateLimitException;
                    break;

                case 'INVALID_LOGIN':
                    throw new BitlyAuthException;
                    break;

                default:
                    throw new BitlyErrorException($data['status_txt']);
                    break;
            }
        }
        return $data;
    }
658765
public function convert(array $rawConfig)
    {
        $return = [];
        foreach ($rawConfig as $key => $value) {
            $return[$key] = $this->getConfigValue($value);
        }

        return $return;
    }
668916
public function toResponse(): array
    {
        $r = [];
        foreach ($this->raw as $cookie) {
            $r[] = (string)$cookie;
        }

        return $r;
    }
662976
public function getValues(string $rawString)
    {
        $regExp = $this->getStrRegExp();
        $params = $this->getParameters();
        $matches = [];

        preg_match_all($regExp, $rawString, $matches);
        array_shift($matches);

        $map = function ($match) {
            return isset($match[0]) ? $match[0] : null;
        };

        return array_combine($params, array_map($map, $matches));
    }
833590
public function getResponseData(): Response
    {
        $connectionResponse = new ConnectionResponseImpl();
        $errorResponse = $this->streamSocket->read();
        if ($errorResponse !== null) {
            $this->getLogger()->error('Send error: ' . $errorResponse);
            $this->streamSocket->disconnect();
            $response = @unpack('Ccommand/Cstatus/Nidentifier', $errorResponse);
            if (!empty($response)) {
                $connectionResponse->setErrorResponse($response);
            } else {
                $connectionResponse->setErrorResponse(null);
            }
        }

        return $connectionResponse;
    }
157164
public function collect($rawData)
    {
        $result = array();

        foreach ($this->collectors as $name => $collectorInstance)
        {
            $result[$name] = $collectorInstance->collect($rawData);
        }

        return $result;
    }
386291
public function get( $key, $raw = false ) {
		return \get_site_transient( $raw ? $key : $this->get_key( $key ) );
	}
236518
protected function getHeadersAsArray($rawHeaders)
    {
        $headers = [];

        foreach (explode("\r\n", (string) $rawHeaders) as $header) {
            if (false !== strpos($header, ':')) {
                list($name, $headerStr) = explode(':', $header, 2);
                $headers[trim($name)] = trim($headerStr);
            }
        }

        return $headers;
    }
1107390
public static function getRawData(): string
    {
        if (static::$rawData === null) {
            static::$rawData = file_get_contents('php://input');

            if (static::$rawData === false) {
                throw new RequestException('Unable to read raw data from request');
            }
        }

        return static::$rawData;
    }
626994
private function parseResponseHeaders($raw_response_headers)
    {
        $response_header_array = explode("\r\n\r\n", $raw_response_headers);
        $response_header  = '';
        for ($i = count($response_header_array) - 1; $i >= 0; $i--) {
            if (stripos($response_header_array[$i], 'HTTP/') === 0) {
                $response_header = $response_header_array[$i];
                break;
            }
        }

        $response_headers = new CaseInsensitiveArray();
        list($first_line, $headers) = $this->parseHeaders($response_header);
        $response_headers['Status-Line'] = $first_line;
        foreach ($headers as $key => $value) {
            $response_headers[$key] = $value;
        }
        return $response_headers;
    }
1104007
protected function getSuccessData($attributes = null)
    {
        $rawData = $this->decodeResponseJson()['data'];

        if (is_null($attributes)) {
            return $rawData;
        } elseif (is_string($attributes)) {
            return array_get($rawData, $attributes);
        }

        $data = [];

        foreach ($attributes as $attribute) {
            $data[] = array_get($rawData, $attribute);
        }

        return $data;
    }
1178301
public static function raw($sql) {
	$exception = bootstrap::get_library('exception');
	$response  = bootstrap::get_library('response');
	
	if (is_null(self::$connection)) {
		throw new $exception('no db connection', $response::STATUS_SERVICE_UNAVAILABLE);
	}
	
	$result = self::$connection->query($sql);
	
	self::$error_number  = self::$connection->errno;
	self::$error_message = self::$connection->error;
	if (self::$error_number) {
		throw new $exception(self::$error_message, self::$error_number);
	}
	
	if ($result instanceof \mysqli_result) {
		self::$num_rows = $result->num_rows;
	}
	self::$insert_id     = self::$connection->insert_id;
	self::$affected_rows = self::$connection->affected_rows;
	
	return $result;
}
630318
public function parse($raw)
    {
        $lines = explode("\n", $raw);

        // Status Line
        preg_match('/HTTP\/(\d\.\d) (\d\d\d) (.*)/', $lines[0], $statusLine);
        $response = (new Response())
            ->withProtocolVersion($statusLine[1])
            ->withStatus($statusLine[2], $statusLine[3]);
        unset($lines[0]);

        // Headers
        foreach ($lines as $i => $line) {
            if ('' == trim($line)) {
                unset($lines[$i]);
                break;
            }
            $header   = explode(': ', $line);
            $response = $response->withHeader($header[0], $header[1]);
            unset($lines[$i]);
        }

        // Body
        $stream = new Stream(fopen('php://memory', 'rw+'));
        $stream->write(implode("\n", $lines));
        $stream->rewind();
        $response = $response->withBody($stream);

        return $response;
    }
759174
public function get()
    {
        if (empty($this->raw_data)) {
            return array();
        }

        $regexp = '/(' . preg_quote(self::SEPARATOR_ELEMENT, '/')
            . '|' . preg_quote(self::SEPARATOR_ITEM, '/') . '[0-9]+' . preg_quote(self::SEPARATOR_LEVEL, '/')
            .')/';

        return preg_split($regexp, $this->raw_data);
    }
215698
protected function parseData($rawData)
    {
        $outputData = [];

        foreach (explode(' ', $rawData) as $data) {
            $data = explode(':', $data);
            $outputData[$data[0]] = $data[1];
        }

        return $outputData;
    }
186946
public function raw(string $data = '', int $status = 200): Response
    {
        $response = $this;

        // Headers
        $response = $response->withoutHeader('Content-Type')->withAddedHeader('Content-Type', 'text/plain');
        $this->getCharset() && $response = $response->withCharset($this->getCharset());

        // Content
        $data && $response = $response->withContent($data);

        // Status code
        $status && $response = $response->withStatus($status);

        return $response;
    }
454207
public function unserialize($raw) {
        $returnData = array();
        $offset     = 0;

        while ($offset < strlen($raw)) {
            $num     = ord($raw[$offset]);
            $offset += 1;
            $varname = substr($raw, $offset, $num);
            $offset += $num;
            $data    = unserialize(substr($raw, $offset));

            $returnData[$varname] = $data;
            $offset += strlen(serialize($data));
        }

        return $returnData;
    }