Passed
Pull Request — master (#27)
by
unknown
11:39
created

SymfonyRequestAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRemoteAddr() 0 3 1
A __construct() 0 2 1
A getHeaders() 0 7 2
1
<?php
2
3
namespace Vectorface\Whip\Request;
4
5
use Symfony\Component\HttpFoundation\Request;
6
7
class SymfonyRequestAdapter implements RequestAdapter
8
{
9
    public function __construct(private Request $request)
10
    {
11
    }
12
    /**
13
     * @inheritDoc
14
     */
15
    public function getRemoteAddr(): ?string
16
    {
17
        return $this->request->getClientIp();
18
    }
19
20
    /**
21
     * @inheritDoc
22
     */
23
    public function getHeaders(): array
24
    {
25
        $headers = [];
26
        foreach ($this->request->headers->all() as $key => $value) {
27
            $headers[$key] = implode(',', $value);
28
        }
29
        return $headers;
30
    }
31
}