Create response object.

@param  string $format
@param  string $engine
@return Response
@throws \DomainException
348495
public static function create($format = self::FORMAT_JSON, $engine = self::ENGINE_API)
    {
        $response = '\Eureka\Component\Response';

        switch ($format) {
            //~ Json
            case self::FORMAT_JSON:
                $responseFormat = '\Json';
                break;
            //~ Html
            case self::FORMAT_HTML:
                $responseFormat = '\Html';
                break;
            //~ Other
            case self::FORMAT_XML:
            case self::FORMAT_TEXT:
            default:
                throw new \DomainException('Unsupported output format !');
        }

        switch ($engine) {
            //~ Api Engine
            case self::ENGINE_API:
                $response .= $responseFormat . '\Api';
                break;
            //~ Layout Engine
            case self::ENGINE_TEMPLATE:
                $response .= $responseFormat . '\Template';
                break;
            //~ None
            case self::ENGINE_NONE:
                $response .= $responseFormat . $responseFormat;
                //~ Do not add engine name to the class name.
                break;
            //~ Other
            default:
                throw new \DomainException('Unsupported output engine !');
        }

        $responseInstance = new $response();

        return $responseInstance;
    }
278378
protected function createResponse($pid, $alias, $timeout = 0.0, $timeoutIncrease = 1.0)
    {
        return new ResponseRecord($pid, $alias, $timeout, $timeoutIncrease);
    }
1371510
public function create(string $data): Response
    {
        $header = unpack('C2', substr($data, 3, 2));
        $size = $header[1];
        $type = $header[2];
        $payload = substr($data, 5, $size);
        $this->validateCrc($payload, $data);

        switch ($type) {
            case MotorStatus::TYPE:
                return new MotorStatus($payload);
            case Attitude::TYPE:
                return new Attitude($payload);
            default:
                throw new InvalidCommandTypeException($type);
        }
    }
1165282
public static function createFromFormat( $format, $time, $timezone = null )
    {

        $dateTime = \DateTime::createFromFormat(
            $format,
            $time,
            self::fixTimezone( $timezone )
        );

        if( !( $dateTime instanceof \DateTime ) ){
            return null;
        }

        return new DateTime(
            $dateTime->format( \DateTime::ISO8601 ),
            self::fixTimezone( $timezone )
        );

    }
913260
public function setFilterFormat(string $format = 'DD MMM YY'): ColumnInterface
    {
        $this->filter[self::FILTER_KEY_FORMAT] = $format;

        return $this;
    }
172834
protected function createSubscription(ProcessEngine $engine, ?Job $job = null): void
    {
        $execution = $engine->findExecution($this->executionId);
        $nodeId = ($this->nodeId === null) ? null : $execution->getProcessModel()->findNode($this->nodeId)->getId();
        
        $data = [
            'id' => UUID::createRandom(),
            'execution_id' => $execution->getId(),
            'activity_id' => $this->activityId,
            'node' => $nodeId,
            'process_instance_id' => $execution->getRootExecution()->getId(),
            'flags' => $this->getSubscriptionFlag(),
            'boundary' => $this->boundaryEvent ? 1 : 0,
            'name' => $this->name,
            'created_at' => \time()
        ];
        
        if ($job !== null) {
            $data['job_id'] = $job->getId();
        }
        
        $engine->getConnection()->insert('#__bpmn_event_subscription', $data);
    }
427977
protected function createResponse($response, Exception $e)
    {
        $response = new HttpResponse($response->getContent(), $response->getStatusCode(), $response->headers->all());

        return $response->withException($e);
    }
82407
private function createJavascriptResponse($content)
    {
        $rf = $this->app->make(ResponseFactoryInterface::class);

        return $rf->create(
            $content,
            200,
            [
                'Content-Type' => 'application/javascript; charset=' . APP_CHARSET,
                'Content-Length' => strlen($content),
            ]
        );
    }
171556
public static function getFormatClass($format)
    {
        // Return a namespace in a given format
        $class = sprintf('%s\Format\%sFormat', __NAMESPACE__, ucfirst(strtolower($format)));

        if (!class_exists($class)) {
            throw new \DomainException(
                sprintf(
                    'Structure format: %s not supported. Class: %s not found.',
                    $format,
                    $class
                )
            );
        }

        return $class;
    }
832242
public static function createFromFormat($format, $date, $tz = null) {
        
        if ($tz !== null) {
            $tz = static::safeCreateDateTimeZone($tz);
        }
        
        $instance = new static($tz);
        
        $instance->parseFormat($format, $date);
        
        return $instance;
    }
272954
public function createResponse(Expectation $expectation, TransactionData $transactionData)
    {
        $responseConfig = $expectation->getResponse();
        $httpResponse = $transactionData->getResponse();
        $httpResponse = $this->getResponseWithBody($responseConfig, $httpResponse);
        $httpResponse = $this->getResponseWithStatusCode($responseConfig, $httpResponse);
        $httpResponse = $this->getResponseWithHeaders($responseConfig, $httpResponse);
        $this->processDelay($responseConfig);

        return $httpResponse;
    }
1138372
public function create(
        $object,
        string $accept,
        int $status = 200,
        NormalizerContextInterface $context = null
    ): ResponseInterface {
        $body = $this->serializer->serialize($object, $accept, $context);

        $response = $this->responseFactory->createResponse($status)->withHeader('Content-Type', $accept);
        $response->getBody()->write($body);

        return $response;
    }
732698
public function responseProcessor($response, $format, $curlError)
    {
        $format = (is_null($format)) ? $this->config->getFormat() : $format;
        switch ($format) {
            case 'json':
                return $response;
            case 'object':
                if ('NO_CURL_ERROR' == current($curlError)) {
                    return json_decode($response);
                } else {
                    $responseError = new \stdClass();
                    $responseError->error = $curlError;
                    return $responseError;
                }
                break;
            default:
                throw new BadParametersException(
                    sprintf('the "%s" format is not supported.', $format)
                );
        }
    }
741520
public function create(DomainForm $form): Domain
    {
        $model = Domain::create($form->name, $form->alias, $form->url);
        $this->repository->save($model);
        return $model;
    }
58603
public static function createFromFormat($format, $time, $timezone = null)
    {
        $parent = parent::createFromFormat($format, $time);

        if (empty($parent)) {
            throw new TypeException('Could not create Date from the given format');
        }

        $timestamp = $parent->getTimestamp();
        $date = new self();
        $date->setTimestamp($timestamp);

        return $date;
    }
528019
public static function createFromString($locale, $format = self::UNDERSCORE)
    {
        $delimiter = '-';
        if (in_array($format, [self::UNDERSCORE, self::LCID])) {
            $delimiter = '_';
        }

        $parts = explode($delimiter, $locale);

        $localization = new self();
        $localization->setLanguage(strtolower($parts[0]));
        if (count($parts) > 1) {
            $localization->setCountry(strtolower($parts[1]));
        }

        return $localization;
    }
417577
protected function createResponse($xml)
    {
        $requestClass = get_class($this);
        $responseClass = substr($requestClass, 0, -7) . 'Response';
        return $this->response = new $responseClass($this, $xml);
    }