getUrldecodedRequestBody()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 3 Features 0
Metric Value
eloc 5
c 3
b 3
f 0
dl 0
loc 11
rs 10
cc 3
nc 3
nop 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Yves\Heidelpay\Controller;
9
10
use Spryker\Yves\Kernel\Controller\AbstractController;
11
use SprykerEco\Yves\Heidelpay\HeidelpayConfigInterface;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpFoundation\StreamedResponse;
14
15
/**
16
 * @method \SprykerEco\Yves\Heidelpay\HeidelpayFactory getFactory()
17
 */
18
class BaseHeidelpayController extends AbstractController
19
{
20
    /**
21
     * @param \Symfony\Component\HttpFoundation\Request $request
22
     *
23
     * @return array
24
     */
25
    protected function getUrldecodedRequestBody(Request $request): array
26
    {
27
        $allRequestParameters = $request->request->all();
28
29
        foreach ($allRequestParameters as $key => $value) {
30
            if (is_string($value)) {
31
                $allRequestParameters[$key] = urldecode($value);
32
            }
33
        }
34
35
        return $allRequestParameters;
36
    }
37
38
    /**
39
     * @return \SprykerEco\Yves\Heidelpay\HeidelpayConfigInterface
40
     */
41
    protected function getConfig(): HeidelpayConfigInterface
42
    {
43
        return $this->getFactory()->getConfig();
44
    }
45
46
    /**
47
     * @param callable|null $callback
48
     * @param int $status
49
     * @param array $headers
50
     *
51
     * @return \Symfony\Component\HttpFoundation\StreamedResponse
52
     */
53
    protected function streamedResponse($callback = null, $status = 200, $headers = []): StreamedResponse
54
    {
55
        $streamedResponse = new StreamedResponse($callback, $status, $headers);
56
        $streamedResponse->send();
57
58
        return $streamedResponse;
59
    }
60
}
61