Completed
Pull Request — master (#9)
by Volodymyr
16:10 queued 05:16
created

PaypalExpressController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 8
dl 0
loc 30
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A addShipmentAction() 0 7 1
A successAction() 0 8 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\Braintree\Controller;
9
10
use Spryker\Yves\Kernel\Controller\AbstractController;
11
use SprykerEco\Yves\Braintree\Form\CheckoutShipmentForm;
12
use SprykerShop\Yves\CheckoutPage\Plugin\Provider\CheckoutPageControllerProvider;
13
use Symfony\Component\HttpFoundation\Request;
14
use Symfony\Component\HttpFoundation\Response;
15
16
/**
17
 * @method \SprykerEco\Yves\Braintree\BraintreeFactory getFactory()
18
 */
19
class PaypalExpressController extends AbstractController
20
{
21
    /**
22
     * @param \Symfony\Component\HttpFoundation\Request $request
23
     *
24
     * @return \Symfony\Component\HttpFoundation\JsonResponse
25
     */
26
    public function successAction(Request $request): Response
27
    {
28
        $payload = $this->getFactory()->getUtilEncodingService()->decodeJson($request->getContent(), true);
29
30
        $this->getFactory()->createResponseProcessor()->processSuccessResponse($payload);
0 ignored issues
show
Bug introduced by
It seems like $payload can also be of type null; however, parameter $payload of SprykerEco\Yves\Braintre...rocessSuccessResponse() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

30
        $this->getFactory()->createResponseProcessor()->processSuccessResponse(/** @scrutinizer ignore-type */ $payload);
Loading history...
31
32
        return $this->jsonResponse([
33
            'redirectUrl' => $this->getApplication()->path(CheckoutPageControllerProvider::CHECKOUT_SUMMARY),
34
        ]);
35
    }
36
37
    /**
38
     * @param \Symfony\Component\HttpFoundation\Request $request
39
     *
40
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
41
     */
42
    public function addShipmentAction(Request $request): Response
43
    {
44
        $idShipmentMethod = $request->get(CheckoutShipmentForm::FORM_NAME)[CheckoutShipmentForm::FIELD_ID_SHIPMENT_METHOD];
45
46
        $this->getFactory()->createQuoteExpander()->expandQuoteWithShipmentMethod($request, $idShipmentMethod);
47
48
        return $this->redirectResponseInternal(CheckoutPageControllerProvider::CHECKOUT_SUMMARY);
49
    }
50
}
51