for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kami\ApiCoreBundle\RequestProcessor;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class ProcessorResponse implements ResponseInterface
{
/**
* @var array
*/
protected $data;
* @var Request
protected $request;
* @var int
protected $status;
* @var bool
protected $isHttpReady = false;
public function __construct(Request $request, array $data, $httpReady = false, $status = 200)
$status
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function __construct(Request $request, array $data, $httpReady = false, /** @scrutinizer ignore-unused */ $status = 200)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$this->request = $request;
$this->data = $data;
$this->isHttpReady = $httpReady;
}
public function toHttpResponse()
if (!$this->isHttpReady) {
throw new ProcessingException('Response is not ready yet to be set as http');
$this->createResponse($this->request);
* @return mixed
public function getData()
return $this->data;
* @param Request $request
*
* @return Response
private function createResponse(Request $request)
$format = $request->attributes->get('_format');
return new Response(
$this->data['response_data'],
$this->status,
['Content-type' => $this->getContentTypeByFormat($format)]
);
* @param string $format
* @return string
private function getContentTypeByFormat($format)
switch ($format) {
case 'json':
return 'application/json';
break;
break
The break statement is not necessary if it is preceded for example by a return statement:
return
switch ($x) { case 1: return 'foo'; break; // This break is not necessary and can be left off. }
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.
case
case 'xml':
return 'application/xml';
default:
return 'text/plain';
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.