| Total Complexity | 13 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 8 | class RequestProcessor implements ProcessorInterface { |
||
| 9 | |||
| 10 | private ?string $userAgent = null; |
||
| 11 | private ?string $url = null; |
||
| 12 | private ?string $referer = null; |
||
| 13 | |||
| 14 | public function __construct(private RequestStack $requestStack) |
||
| 15 | { |
||
| 16 | } |
||
| 17 | |||
| 18 | /** |
||
| 19 | * @inheritDoc |
||
| 20 | */ |
||
| 21 | public function __invoke(array $records): array { |
||
| 22 | $records['extra']['useragent'] = $this->getUserAgent(); |
||
| 23 | $records['extra']['url'] = $this->getUrl(); |
||
| 24 | $records['extra']['referer'] = $this->getXhrBaseUrl(); |
||
| 25 | |||
| 26 | return $records; |
||
| 27 | } |
||
| 28 | |||
| 29 | private function getUserAgent(): ?string { |
||
| 30 | if($this->userAgent === null && $this->requestStack->getMainRequest() !== null) { |
||
| 31 | $this->userAgent = $this->requestStack->getMainRequest()->headers->get('User-Agent'); |
||
| 32 | } |
||
| 33 | |||
| 34 | return $this->userAgent; |
||
| 35 | } |
||
| 36 | |||
| 37 | private function getUrl(): ?string { |
||
| 43 | } |
||
| 44 | |||
| 45 | private function getXhrBaseUrl(): ?string { |
||
| 46 | if($this->referer === null && $this->requestStack->getMainRequest() !== null) { |
||
| 60 | } |
||
| 61 | } |