HttpPayloadResolver   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolvePayload() 0 11 2
A shouldNotHasRequestBody() 0 4 1
1
<?php
2
3
namespace Fesor\RequestObject;
4
5
use Symfony\Component\HttpFoundation\Request;
6
7
class HttpPayloadResolver implements PayloadResolver
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12
    public function resolvePayload(Request $request)
13
    {
14
        if ($this->shouldNotHasRequestBody($request->getMethod())) {
15
            return $request->query->all();
16
        }
17
18
        return array_merge(
19
            $request->request->all(),
20
            $request->files->all()
21
        );
22
    }
23
24
    private function shouldNotHasRequestBody($methodName)
25
    {
26
        return in_array($methodName, ['GET', 'HEAD', 'DELETE'], true);
27
    }
28
}
29