for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the KleijnWeb\SwaggerBundle package.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace KleijnWeb\SwaggerBundle\Response;
use KleijnWeb\SwaggerBundle\Document\DocumentRepository;
use KleijnWeb\SwaggerBundle\Serializer\SerializerAdapter;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
/**
* @author John Kleijn <[email protected]>
class ResponseFactory
{
* @var SerializerAdapter
private $serializer;
* @var DocumentRepository
private $documentRepository;
* @param DocumentRepository $documentRepository
* @param SerializerAdapter $serializer
public function __construct(DocumentRepository $documentRepository, SerializerAdapter $serializer)
$this->serializer = $serializer;
$this->documentRepository = $documentRepository;
}
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
* @param Request $request
* @param mixed $data
* @return Response
public function createResponse(Request $request, $data)
$request
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
$headers = ['Content-Type' => 'application/json'];
if ($data === null) {
return new Response('', 204, $headers);
$data = $this->serializer->serialize($data, 'json');
return new Response($data, 200, $headers);
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.