This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
22
{
23
/**
24
* @var Request
25
*/
26
private $request;
27
/**
28
* @var RequestIdGenerator
29
*/
30
private $generator;
31
32
/**
33
* @param RequestIdGenerator $generator
34
*/
35
public function __construct(RequestIdGenerator $generator)
36
{
37
$this->generator = $generator;
38
}
39
40
/**
41
* @return RequestIdProvider
42
*/
43
public function create()
44
{
45
return new ExtractsRequestIdFromHeader($this->request, new DefaultRequestIdProvider($this->generator));
You have injected the Request via parameter $request. This is generally not recommended as there might be multiple instances during a request cycle (f.e. when using sub-requests). Instead, it is recommended to inject the RequestStack and retrieve the current request each time you need it via getCurrentRequest().
Loading history...
52
{
53
if (!$request instanceof Request) {
54
throw new \InvalidArgumentException('Invalid argument received. Expected: '.Request::class);
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.