src/includes/classes/Core/Response.php
public function withSuccess(int $status, $data, bool $as_json = null): self
    {
        $is_data_array = is_array($data);

        if (!isset($as_json) && $is_data_array) {
            $as_json = $this->App->c::isApi() || $this->App->c::isAjax();
        }
        if ($as_json) { // Format as JSON?
            $content_type = 'application/json';
            $data         = $is_data_array ? $data : [];
            $content      = json_encode(['success' => true] + $data, JSON_PRETTY_PRINT);
        } else {
            $content      = is_string($data) ? $data : '';
            $content_type = 'text/'.($this->App->c::isHtml($content, true) ? 'html' : 'plain');
        }
        $clone = $this->withStatus($status);
        $clone = $clone->withHeader('content-type', $content_type.'; charset=utf-8');

        $Body         = $this->App->c::createReponseBody($content);
        return $clone = $clone->withBody($Body);
    }
public function withSuccess(int $status, $data, bool $as_json = null): self
    {
        $is_data_array = is_array($data);

        if (!isset($as_json) && $is_data_array) {
            $as_json = $this->App->c::isApi() || $this->App->c::isAjax();
        }
        if ($as_json) { // Format as JSON?
            $content_type = 'application/json';
            $data         = $is_data_array ? $data : [];
            $content      = json_encode(['success' => true] + $data, JSON_PRETTY_PRINT);
        } else {
            $content      = is_string($data) ? $data : '';
            $content_type = 'text/'.($this->App->c::isHtml($content, true) ? 'html' : 'plain');
        }
        $clone = $this->withStatus($status);
        $clone = $clone->withHeader('content-type', $content_type.'; charset=utf-8');

        $Body         = $this->App->c::createReponseBody($content);
        return $clone = $clone->withBody($Body);
    }
Success response.

@since 17xxxx Response utils.

@param int          $status  Status.
@param array|string $data    Props/markup.
@param bool         $as_json As JSON?

@return Response w/ success response.