public function dispatch(ResponseInterface $response, int $status, $result)
    {
        // Build output array
        $contents = [
            'status' => $status,
            'result' => $result,
        ];

        // Convert output to JSON
        $contents = json_encode($contents, JSON_PRETTY_PRINT);

        // Write Response to Body
        $response->getBody()->write($contents);

        // PSR-7 response
        return $response->withStatus($status); 
    }
public function dispatch(ResponseInterface $response, int $status, $result)
    {
        // Build output array
        $contents = [
            'status' => $status,
            'result' => $result,
        ];

        // Convert output to JSON
        $contents = json_encode($contents, JSON_PRETTY_PRINT);

        // Write Response to Body
        $response->getBody()->write($contents);

        // PSR-7 response
        return $response->withStatus($status); 
    }
public function dispatch ( ResponseInterface $ response , int $ status , $ result ) { // Build output array $ contents = [ 'status' => $ status , 'result' => $ result , ] ; // Convert output to JSON $ contents = json_encode ( $ contents , JSON_PRETTY_PRINT ) ; // Write Response to Body $ response -> getBody ( ) -> write ( $ contents ) ; // PSR-7 response return $ response -> withStatus ( $ status ) ; }
JSON response class

@param ResponseInterface $response PSR-7 HTTP response message
@param Integer           $status   HTTP status (e.g: 200)
@param Mixed             $result   Array, String or Object to send as JSON response
JSON response class