Passed
Branch master (acde85)
by Alexander
01:40
created

Index::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace B2Binpay\Payment\Controller\Redirect;
4
5
use Magento\Checkout\Model\Session as CheckoutSession;
0 ignored issues
show
Bug introduced by
The type Magento\Checkout\Model\Session 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...
6
use Magento\Framework\App\Action\Context;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Action\Context 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...
7
use Magento\Framework\Controller\Result\JsonFactory;
0 ignored issues
show
Bug introduced by
The type Magento\Framework\Controller\Result\JsonFactory 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...
8
use Psr\Log\LoggerInterface;
0 ignored issues
show
Bug introduced by
The type Psr\Log\LoggerInterface 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...
9
10
class Index extends \Magento\Framework\App\Action\Action
0 ignored issues
show
Bug introduced by
The type Magento\Framework\App\Action\Action 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
{
12
    /**
13
     * @var CheckoutSession
14
     */
15
    protected $checkoutSession;
16
17
    /**
18
     * @var JsonFactory
19
     */
20
    protected $resultJsonFactory;
21
22
    /**
23
     * @var LoggerInterface
24
     */
25
    protected $logger;
26
27
    /**
28
     * Redirect Controller.
29
     *
30
     * @param Context $context
31
     * @param CheckoutSession $checkoutSession
32
     * @param JsonFactory $resultJsonFactory
33
     * @param LoggerInterface $logger
34
     */
35
    public function __construct(
36
        Context $context,
37
        CheckoutSession $checkoutSession,
38
        JsonFactory $resultJsonFactory,
39
        LoggerInterface $logger
40
    ) {
41
        parent::__construct(
42
            $context
43
        );
44
45
        $this->checkoutSession = $checkoutSession;
46
        $this->resultJsonFactory = $resultJsonFactory;
47
        $this->logger = $logger;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    public function execute()
54
    {
55
        $order = $this->checkoutSession->getLastRealOrder();
56
57
        $payment = $order->getPayment();
58
59
        $post_data = [
60
            'url' => $payment->getAdditionalInformation('redirect_url')
61
        ];
62
63
        $result = $this->resultJsonFactory->create();
64
65
        return $result->setData($post_data);
66
    }
67
}
68