1 | <?php |
||
2 | |||
3 | /** |
||
4 | * MIT License |
||
5 | * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
||
6 | */ |
||
7 | |||
8 | namespace SprykerEco\Yves\Ratepay\Widget; |
||
9 | |||
10 | use Generated\Shared\Transfer\QuoteTransfer; |
||
0 ignored issues
–
show
|
|||
11 | use Spryker\Shared\Kernel\Transfer\AbstractTransfer; |
||
12 | use Spryker\Yves\Kernel\Widget\AbstractWidget; |
||
13 | use SprykerEco\Shared\Ratepay\RatepayConfig; |
||
14 | |||
15 | /** |
||
16 | * @method \SprykerEco\Yves\Ratepay\RatepayFactory getFactory() |
||
17 | */ |
||
18 | class RatepaySummaryWidget extends AbstractWidget |
||
19 | { |
||
20 | protected const PARAMETER_RATEPAY_PAYMENT_TRANSFER = 'ratepayPaymentTransfer'; |
||
21 | protected const PARAMETER_QUOTE_TRANSFER = 'quoteTransfer'; |
||
22 | protected const PARAMETER_MOLECULE = 'molecule'; |
||
23 | protected const PARAMETER_MODULE = 'module'; |
||
24 | |||
25 | protected const NAME = 'RatepaySummaryWidget'; |
||
26 | protected const TEMPLATE = '@Ratepay/views/ratepay-summary-widget/ratepay-summary-widget.twig'; |
||
27 | protected const MODULE = 'Ratepay'; |
||
28 | |||
29 | protected const PAYMENT_TRANSFER_MAP = [ |
||
30 | RatepayConfig::INVOICE => 'getRatepayInvoice', |
||
31 | RatepayConfig::ELV => 'getRatepayElv', |
||
32 | RatepayConfig::INSTALLMENT => 'getRatepayInstallment', |
||
33 | RatepayConfig::PREPAYMENT => 'getRatepayPrepayment', |
||
34 | ]; |
||
35 | |||
36 | /** |
||
37 | * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
||
38 | */ |
||
39 | public function __construct(QuoteTransfer $quoteTransfer) |
||
40 | { |
||
41 | $this->addParameter(static::PARAMETER_RATEPAY_PAYMENT_TRANSFER, $this->getRatepayPaymentTransfer($quoteTransfer)); |
||
42 | $this->addParameter(static::PARAMETER_MOLECULE, $this->getMoleculeName($quoteTransfer)); |
||
43 | $this->addParameter(static::PARAMETER_QUOTE_TRANSFER, $quoteTransfer); |
||
44 | $this->addParameter(static::PARAMETER_MODULE, static::MODULE); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @return string |
||
49 | */ |
||
50 | public static function getName(): string |
||
51 | { |
||
52 | return static::NAME; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @return string |
||
57 | */ |
||
58 | public static function getTemplate(): string |
||
59 | { |
||
60 | return static::TEMPLATE; |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
||
65 | * |
||
66 | * @return \Spryker\Shared\Kernel\Transfer\AbstractTransfer|null |
||
67 | */ |
||
68 | protected function getRatepayPaymentTransfer(QuoteTransfer $quoteTransfer): ?AbstractTransfer |
||
69 | { |
||
70 | $paymentTransfer = $quoteTransfer->getPayment(); |
||
71 | |||
72 | if (!isset(static::PAYMENT_TRANSFER_MAP[$paymentTransfer->getPaymentMethod()])) { |
||
73 | return null; |
||
74 | } |
||
75 | |||
76 | $getterName = static::PAYMENT_TRANSFER_MAP[$paymentTransfer->getPaymentMethod()]; |
||
77 | |||
78 | if (!method_exists($paymentTransfer, $getterName)) { |
||
79 | return null; |
||
80 | } |
||
81 | |||
82 | return $quoteTransfer->getPayment()->$getterName(); |
||
83 | } |
||
84 | |||
85 | /** |
||
86 | * @param \Generated\Shared\Transfer\QuoteTransfer $quoteTransfer |
||
87 | * |
||
88 | * @return string |
||
89 | */ |
||
90 | protected function getMoleculeName(QuoteTransfer $quoteTransfer): string |
||
91 | { |
||
92 | return strtolower($quoteTransfer->getPayment()->getPaymentMethod()); |
||
93 | } |
||
94 | } |
||
95 |
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