Issues (570)

Gateway/SubjectReader.php (8 issues)

1
<?php
2
/**
3
 * Copyright © Wirecard Brasil. All rights reserved.
4
 *
5
 * @author    Bruno Elisei <[email protected]>
6
 * See COPYING.txt for license details.
7
 */
8
9
declare(strict_types=1);
10
11
namespace Moip\Magento2\Gateway;
12
13
use Magento\Checkout\Model\Session;
0 ignored issues
show
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...
14
use Magento\Payment\Gateway\Data\PaymentDataObjectInterface;
0 ignored issues
show
The type Magento\Payment\Gateway\...mentDataObjectInterface 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...
15
use Magento\Payment\Gateway\Helper;
0 ignored issues
show
The type Magento\Payment\Gateway\Helper 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...
16
17
/**
18
 * Class SubjectReader - Reading data.
19
 */
20
class SubjectReader
21
{
22
    /**
23
     * @var Checkout Session
0 ignored issues
show
The type Moip\Magento2\Gateway\Checkout 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...
24
     */
25
    private $checkoutSession;
26
27
    /**
28
     * SubjectReader constructor.
29
     *
30
     * @param Session $checkoutSession
31
     */
32
    public function __construct(
33
        Session $checkoutSession
34
    ) {
35
        $this->checkoutSession = $checkoutSession;
36
    }
37
38
    /**
39
     * Reads payment from subject.
40
     *
41
     * @param array $subject
42
     *
43
     * @return PaymentDataObjectInterface
44
     */
45
    public function readPayment(array $subject): PaymentDataObjectInterface
46
    {
47
        return Helper\SubjectReader::readPayment($subject);
0 ignored issues
show
The type Magento\Payment\Gateway\Helper\SubjectReader 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...
48
    }
49
50
    /**
51
     * Reads store's ID, otherwise returns null.
52
     *
53
     * @param array $subject
54
     *
55
     * @return int|null
56
     */
57
    public function readStoreId(array $subject): int
58
    {
59
        $storeId = $subject['store_id'] ?? null;
60
61
        if (empty($storeId)) {
62
            try {
63
                $storeId = (int) $this->readPayment($subject)
64
                    ->getOrder()
65
                    ->getStoreId();
66
                // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
67
            } catch (\InvalidArgumentException $e) {
68
                // No store id is current set
69
            }
70
        }
71
72
        return $storeId ? (int) $storeId : null;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $storeId ? (int)$storeId : null could return the type null which is incompatible with the type-hinted return integer. Consider adding an additional type-check to rule them out.
Loading history...
73
    }
74
75
    /**
76
     * Reads amount from subject.
77
     *
78
     * @param array $subject
79
     *
80
     * @return string
81
     */
82
    public function readAmount(array $subject): string
83
    {
84
        return (string) Helper\SubjectReader::readAmount($subject);
85
    }
86
87
    /**
88
     * Reads response from subject.
89
     *
90
     * @param array $subject
91
     *
92
     * @return array
93
     */
94
    public function readResponse(array $subject): array
95
    {
96
        return Helper\SubjectReader::readResponse($subject);
97
    }
98
99
    /**
100
     * @return \Magento\Quote\Model\Quote
0 ignored issues
show
The type Magento\Quote\Model\Quote 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...
101
     */
102
    public function getQuote()
103
    {
104
        return $this->checkoutSession->getQuote();
105
    }
106
107
    /**
108
     * @return \Magento\Sales\Model\Order
0 ignored issues
show
The type Magento\Sales\Model\Order 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...
109
     */
110
    public function getOrder()
111
    {
112
        return $this->checkoutSession->getLastRealOrder();
113
    }
114
}
115