Build response object from compiler response data

@param array $data
@return CompilerResponse
326641
protected function buildResponse($data)
    {
        $response = $this->getCompilerResponse();

        foreach ($data as $item) {
            if (!isset($item['tag']) && !isset($item['value'])) {
                continue;
            }

            if (isset($item['tag']) && ($item['tag'] == 'errors' || $item['tag'] == 'warnings')) {
                foreach ($item['value'] as $error) {
                    $attributes = $error['attributes'];
                    
                    $error = new CompilerResponseError($error['value'], array(
                        'type' => $attributes['type'],
                        'file' => $attributes['file'],
                        'line' => $attributes['lineno'],
                        'char' => $attributes['charno'],
                        'code' => $attributes['line'],
                    ));

                    if ($item['tag'] == 'errors') {
                        $response->addError($error);
                    } else {
                        $response->addWarning($error);
                    }
                }
            } elseif (is_array($item['value'])) {
                $this->buildResponse($item['value']);
            } else {
                $method = 'set' . ucfirst($item['tag']);
                if (method_exists($response, $method)) {
                    call_user_func_array(array($response, $method), array($item['value']));
                }
            }
        }

        return $response;
    }
371688
public function unserialize($data) //@codingStandardsIgnoreLine Interface does not define type-hints or return
    {
        $this->ensure(is_array($data), '$data was not an array');
        return new Response(
            Arrays::get($data, 'statusCode'),
            Arrays::get($data, 'headers'),
            Arrays::get($data, 'body'),
            Arrays::get($data, 'protocolVersion'),
            Arrays::get($data, 'reasonPhrase')
        );
    }
1180361
protected function prepare($data = [])
    {
        if (($response = $this->callSubmitted()) instanceof Response) {
            return $response;
        }

        $this->inputs = array_merge($this->removeIgnoredFields($data), $this->inputs);

        if (($response = $this->callSaving()) instanceof Response) {
            return $response;
        }

        $this->relations = $this->getRelationInputs($this->inputs);

        $this->updates = Arr::except($this->inputs, array_keys($this->relations));
    }
940958
public function create($data = [])
    {
        if (! $data) {
            $data = $this->data;
        } else {
            $this->populate($data);
        }

        $response = $this->client->post('', [], $data);

        if (!$response->hasErrors()) {
            $this->event->dispatch('SUBSCRIPTION.UPDATE', new SubscriptionsEvent($this->data));
        }

        return $this;
    }
1179785
public function create($data)
    {
        set_time_limit(0);
        ignore_user_abort(true);
        //TODO magical value
        ini_set('memory_limit', '1800M');
        $verbose = $this->params()->fromQuery('verbose', false);
        $verbose = ($verbose !== false);
        $responseContent = array();
        $processExecutionHandler = $this->getProcessExecutionHandler();
        $processInformation = $processExecutionHandler->executeNextProcess($verbose);
        $processUpdater = $this->getProcessUpdater();
        $processUpdater->cleanOldExecutions();
        $response = $this->getResponse();
        $response->getHeaders()->addHeaderLine('Content-Type', 'application/json');
        $adapter = new Json();
        $response->setContent($adapter->serialize($processInformation));
        return $response;
    }
201394
public function fromResponse(array $data)
    {
        $map = array(
            'id' => 'setId',
            'start' => 'setStart',
            'end' => 'setEnd',
            'hash' => 'setHash',
            'parameters' => 'setParameters',
            'created_at' => 'setCreatedAt',
            //only present in responses
            'progress' => 'setProgress',
            'status' => 'setStatus',
            'feeds' => 'setFeeds',
            'sample' => 'setSample',
            'data' => 'setData',
        );

        foreach ($map as $key => $setter) {
            if (isset($data[$key])) {
                $this->$setter($data[$key]);
            }
        }

        return $this;
    }
1236154
public function build(array $data = array())
    {
        $data += array(
            'page' => 1,
            'limit' => 0,
            'total' => 0,
            'mini' => false,
            'max_pages' => 10,
            'query' => array()
        );

        $this->setPage($data['page'])
            ->setPerPage($data['limit'])
            ->setTotal($data['total'])
            ->setMaxPages($data['max_pages'])
            ->setUrlPattern('?' . urldecode(http_build_query($data['query'])));

        return $this;
    }
1017963
public static function fromArray(array $data)
	{
		return new self(
			!empty($data['code'])    ? $data['code']    : null,
			!empty($data['message']) ? $data['message'] : null,
			!empty($data['data'])    ? $data['data']    : null
		);
	}
545407
public function getJsonResponse($data)
    {
        $view = new JsonModel();
        $view->setTerminal(true);

        $response = $this->getResponse();
        $response->setContent(json_encode($data));

        return $response;
    }
490100
public function setResponse(array $data = null)
    {
        $this->DataArray    = $data;
        $this->ResponseData = json_encode($data);
        return $this;
    }
230388
protected function createResponse($data = null)
    {
        $view = new View();
        $view->setData($data);

        $context = $view->getSerializationContext();
        if ($this->serialization->isCheckDepth()) {
            $context->enableMaxDepthChecks();
        }
        $context->setGroups($this->serialization->getGroups());

        $view->setSerializationContext($context);

        return $this->handleView($view);
    }
800439
public function register(array $data): PodiumResponse
    {
        $registration = $this->getRegisterer();

        if (!$registration->loadData($data)) {
            return PodiumResponse::error();
        }

        return $registration->register();
    }
114344
public static function createFromDecodedJsonResponse($data)
    {
        $areas = [];
        foreach ($data as $name => $area) {
            $areas[$name] = [];
            foreach ($area as $class => $data) {
                $metaClass = DynamicMetadataHelper::getDynamicMetadataClassName($class);
                /* @var DynamicMetadataInterface $metaClass */
                $areas[$name][] = $metaClass::createFromDecodedJsonResponse($data);
            }
        }

        return new self($areas);
    }
261938
private function step3DatabaseType(array $data): ResponseInterface
    {
        if ($data['errors']->isNotEmpty()) {
            return $this->viewResponse('setup/step-2-server-checks', $data);
        }

        return $this->viewResponse('setup/step-3-database-type', $data);
    }
276885
protected function buildCustomResponseProcessing(DOMElement $data){

        // Parse to find the different response rules
        $responseRules = array();

        $data = simplexml_import_dom($data);

        $returnValue = new Custom($responseRules, $data->asXml());

        return $returnValue;
    }
644123
public function execute(array $data): JsonResponse
    {
        $this->debug('link_shared', ['event' => $data]);

        /** @var UnfurlEvent $event */
        $event = $this->dispatcher->dispatch(Events::SLACK_UNFURL, new UnfurlEvent($data));
        $unfurls = $event->getUnfurls();

        $this->debug('unfurls', ['channel' => $data['channel'], 'ts' => $data['message_ts'], 'unfurls' => $unfurls]);
        if ($unfurls) {
            $this->slackClient->unfurl($data['channel'], $data['message_ts'], $unfurls);
        }

        return new JsonResponse([]);
    }
108316
protected function buildStatusCodes(array $data)
    {
        if (isset($data['statusCodes'])) {
            $this->initializeStatusCodes();
            foreach ($data['statusCodes'] as $key => $element) {
                if ((int) $key < 200) {
                    $this->statusCodes($element);
                } else {
                    $this->statusCodes($key, $element);
                }
            }
        }

        return $this;
    }