Passed
Pull Request — master (#9)
by Volodymyr
05:48
created

PaypalExpressController::addShipmentAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
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;
0 ignored issues
show
Bug introduced by
The type SprykerShop\Yves\Checkou...tPageControllerProvider was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
13
use Symfony\Component\HttpFoundation\Request;
14
15
/**
16
 * @method \SprykerEco\Yves\Braintree\BraintreeFactory getFactory()
17
 */
18
class PaypalExpressController extends AbstractController
19
{
20
    /**
21
     * @param \Symfony\Component\HttpFoundation\Request $request
22
     *
23
     * @return \Symfony\Component\HttpFoundation\JsonResponse
24
     */
25
    public function successAction(Request $request)
26
    {
27
        $payload = $this->getFactory()->getUtilEncodingService()->decodeJson($request->getContent(), true);
28
29
        $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

29
        $this->getFactory()->createResponseProcessor()->processSuccessResponse(/** @scrutinizer ignore-type */ $payload);
Loading history...
30
31
        //TODO: Update route
32
        return $this->jsonResponse([
33
            'redirectUrl' => 'http://www.de.suite-nonsplit.local/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)
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