src/Controller/TaskRunnerController.php
private function createJsonResponse(
        array $tasks,
        $isCollection = false,
        $status = 'OK',
        $httpStatus = JsonResponse::HTTP_OK
    ) {
        $data       = ['status' => $status];
        $key        = $isCollection ? 'tasks' : 'task';
        $data[$key] = $isCollection ? $tasks : $tasks[0];

        return JsonResponse::create($data, $httpStatus)
            ->setEncodingOptions((JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_FORCE_OBJECT));
    }
private function createJsonResponse(
        array $tasks,
        $isCollection = false,
        $status = 'OK',
        $httpStatus = JsonResponse::HTTP_OK
    ) {
        $data       = ['status' => $status];
        $key        = $isCollection ? 'tasks' : 'task';
        $data[$key] = $isCollection ? $tasks : $tasks[0];

        return JsonResponse::create($data, $httpStatus)
            ->setEncodingOptions((JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_FORCE_OBJECT));
    }
private function createJsonResponse ( array $ tasks , $ isCollection = false , $ status = 'OK' , $ httpStatus = JsonResponse :: HTTP_OK ) { $ data = [ 'status' => $ status ] ; $ key = $ isCollection ? 'tasks' : 'task' ; $ data [ $ key ] = $ isCollection ? $ tasks : $ tasks [ 0 ] ; return JsonResponse :: create ( $ data , $ httpStatus ) -> setEncodingOptions ( ( JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_FORCE_OBJECT ) ) ; }
Create a JsonResponse based on an array of tasks.

@param array[] $tasks        The task data.

@param bool    $isCollection Flag if the data is a task collection.

@param string  $status       Status code string.

@param int     $httpStatus   HTTP Status to send.

@return JsonResponse
Create a JsonResponse based on an array of tasks .