Completed
Push — feature/paypal-express ( 45c1ed...8563e1 )
by Oleksandr
22:44 queued 22:43
created

DetailsController::getPaymentEntity()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 9
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\Zed\Braintree\Communication\Controller;
9
10
use Generated\Shared\Transfer\PaymentBraintreeTransfer;
0 ignored issues
show
Bug introduced by
The type Generated\Shared\Transfer\PaymentBraintreeTransfer 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...
11
use Spryker\Zed\Kernel\Communication\Controller\AbstractController;
12
use Symfony\Component\HttpFoundation\Request;
13
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
14
15
/**
16
 * @method \SprykerEco\Zed\Braintree\Communication\BraintreeCommunicationFactory getFactory()
17
 * @method \SprykerEco\Zed\Braintree\Persistence\BraintreeQueryContainerInterface getQueryContainer()
18
 * @method \SprykerEco\Zed\Braintree\Business\BraintreeFacadeInterface getFacade()
19
 * @method \SprykerEco\Zed\Braintree\Persistence\BraintreeRepositoryInterface getRepository()
20
 */
21
class DetailsController extends AbstractController
22
{
23
    /**
24
     * @param \Symfony\Component\HttpFoundation\Request $request
25
     *
26
     * @return array
27
     */
28
    public function indexAction(Request $request)
29
    {
30
        $idPayment = $this->castId($request->get('id-payment'));
31
        $paymentBraintreeTransfer = $this->getPaymentBraintreeTransfer($idPayment);
32
        $requestLogTable = $this->getFactory()->createRequestLogTable($idPayment);
33
        $statusLogTable = $this->getFactory()->createStatusLogTable($idPayment);
34
35
        return [
36
            'idPayment' => $idPayment,
37
            'paymentDetails' => $paymentBraintreeTransfer,
38
            'requestLogTable' => $requestLogTable->render(),
39
            'statusLogTable' => $statusLogTable->render(),
40
        ];
41
    }
42
43
    /**
44
     * @param int $idPayment
45
     *
46
     * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
47
     *
48
     * @return \Generated\Shared\Transfer\PaymentBraintreeTransfer
49
     */
50
    protected function getPaymentBraintreeTransfer($idPayment): PaymentBraintreeTransfer
51
    {
52
        $paymentBraintreeTransfer = $this->getRepository()->findPaymentBraintreeById($idPayment);
53
54
        if ($paymentBraintreeTransfer === null) {
55
            throw new NotFoundHttpException('Payment entity could not be found');
56
        }
57
58
        return $paymentBraintreeTransfer;
59
    }
60
61
    /**
62
     * @param \Symfony\Component\HttpFoundation\Request $request
63
     *
64
     * @return \Symfony\Component\HttpFoundation\JsonResponse
65
     */
66
    public function requestLogTableAction(Request $request)
67
    {
68
        $idPayment = $this->castId($request->get('id-payment'));
69
        $requestLogTable = $this->getFactory()->createRequestLogTable($idPayment);
70
71
        return $this->jsonResponse($requestLogTable->fetchData());
72
    }
73
74
    /**
75
     * @param \Symfony\Component\HttpFoundation\Request $request
76
     *
77
     * @return \Symfony\Component\HttpFoundation\JsonResponse
78
     */
79
    public function statusLogTableAction(Request $request)
80
    {
81
        $idPayment = $this->castId($request->get('id-payment'));
82
        $statusLogTable = $this->getFactory()->createStatusLogTable($idPayment);
83
84
        return $this->jsonResponse($statusLogTable->fetchData());
85
    }
86
}
87