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 | namespace Moip\Magento2\Gateway\Request; |
||
10 | |||
11 | use Magento\Payment\Gateway\Request\BuilderInterface; |
||
0 ignored issues
–
show
|
|||
12 | use Moip\Magento2\Gateway\Config\Config; |
||
13 | use Moip\Magento2\Gateway\SubjectReader; |
||
14 | |||
15 | /** |
||
16 | * Class PurchasedItemsDataRequest - Data structure of purchased items. |
||
17 | */ |
||
18 | class PurchasedItemsDataRequest implements BuilderInterface |
||
19 | { |
||
20 | /** |
||
21 | * BillingAddress block name. |
||
22 | */ |
||
23 | const PURCHASED_ITEMS = 'items'; |
||
24 | |||
25 | /** |
||
26 | * The street address. Maximum 255 characters |
||
27 | * Required. |
||
28 | */ |
||
29 | const PURCHASED_ITEM_PRODUCT = 'product'; |
||
30 | |||
31 | /** |
||
32 | * The street number. 1 or 10 alphanumeric digits |
||
33 | * Required. |
||
34 | */ |
||
35 | const PURCHASED_ITEM_QUANTITY = 'quantity'; |
||
36 | |||
37 | /** |
||
38 | * The district address. Maximum 255 characters |
||
39 | * Required. |
||
40 | */ |
||
41 | const PURCHASED_ITEM_DETAIL = 'detail'; |
||
42 | |||
43 | /** |
||
44 | * The complement address. Maximum 255 characters |
||
45 | * Required. |
||
46 | */ |
||
47 | const PURCHASED_ITEM_PRICE = 'price'; |
||
48 | |||
49 | /** |
||
50 | * The Category Moip |
||
51 | * Optional. |
||
52 | */ |
||
53 | const PURCHASED_ITEM_CATEGORY = 'category'; |
||
54 | |||
55 | /** |
||
56 | * @var SubjectReader |
||
57 | */ |
||
58 | private $subjectReader; |
||
59 | |||
60 | /** |
||
61 | * @var Config |
||
62 | */ |
||
63 | private $config; |
||
64 | |||
65 | /** |
||
66 | * @param SubjectReader $subjectReader |
||
67 | * @param Config $config |
||
68 | */ |
||
69 | public function __construct( |
||
70 | SubjectReader $subjectReader, |
||
71 | Config $config |
||
72 | ) { |
||
73 | $this->subjectReader = $subjectReader; |
||
74 | $this->config = $config; |
||
75 | } |
||
76 | |||
77 | /** |
||
78 | * {@inheritdoc} |
||
79 | */ |
||
80 | public function build(array $buildSubject) |
||
81 | { |
||
82 | $paymentDO = $this->subjectReader->readPayment($buildSubject); |
||
83 | |||
84 | $result = []; |
||
85 | $order = $paymentDO->getOrder(); |
||
86 | $storeId = $order->getStoreId(); |
||
87 | $items = $order->getItems(); |
||
88 | $itemcount = count($items); |
||
89 | if ($itemcount) { |
||
90 | foreach ($items as $item) { |
||
91 | if ($item->getParentItem()) { |
||
92 | continue; |
||
93 | } |
||
94 | if ($item->getPrice() == 0) { |
||
95 | continue; |
||
96 | } |
||
97 | if ($item->getPrice() > 0) { |
||
98 | $result[self::PURCHASED_ITEMS][] = [ |
||
99 | self::PURCHASED_ITEM_PRODUCT => $item->getName(), |
||
100 | self::PURCHASED_ITEM_QUANTITY => $item->getQtyOrdered(), |
||
101 | self::PURCHASED_ITEM_DETAIL => $item->getSku(), |
||
102 | self::PURCHASED_ITEM_PRICE => $this->config->formatPrice($item->getPrice()), |
||
103 | self::PURCHASED_ITEM_CATEGORY => $this->config->getMoipCategory($storeId), |
||
104 | ]; |
||
105 | } |
||
106 | } |
||
107 | } |
||
108 | |||
109 | return $result; |
||
110 | } |
||
111 | } |
||
112 |
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths