These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Loevgaard\AltaPay\Callback; |
||
4 | |||
5 | use Loevgaard\AltaPay; |
||
6 | use Money\Money; |
||
7 | |||
8 | class Form extends Callback |
||
9 | { |
||
10 | /** |
||
11 | * @var string |
||
12 | */ |
||
13 | protected $shopOrderId; |
||
14 | |||
15 | /** |
||
16 | * @var Money |
||
17 | */ |
||
18 | protected $amount; |
||
19 | |||
20 | /** |
||
21 | * ISO 4217 currency code |
||
22 | * |
||
23 | * @var int |
||
24 | */ |
||
25 | protected $currency; |
||
26 | |||
27 | /** |
||
28 | * ISO 639 alpha 2 language code |
||
29 | * |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $language; |
||
33 | |||
34 | /** |
||
35 | * @var boolean |
||
36 | */ |
||
37 | protected $embeddedWindow; |
||
38 | |||
39 | 6 | public function init() |
|
40 | { |
||
41 | 6 | $currency = (int)$this->body['currency']; |
|
42 | 6 | $alphaCurrency = AltaPay\alphaCurrencyFromNumeric($currency); |
|
43 | |||
44 | 6 | $this->shopOrderId = $this->body['shop_orderid']; |
|
45 | 6 | $this->amount = AltaPay\createMoneyFromFloat($alphaCurrency, (float)$this->body['amount']); |
|
46 | 6 | $this->currency = $currency; |
|
47 | 6 | $this->language = $this->body['language']; |
|
48 | 6 | $this->embeddedWindow = (int)($this->body['embedded_window'] === 1); |
|
0 ignored issues
–
show
|
|||
49 | 6 | } |
|
50 | |||
51 | /** |
||
52 | * @return string |
||
53 | */ |
||
54 | 3 | public function getShopOrderId(): string |
|
55 | { |
||
56 | 3 | return $this->shopOrderId; |
|
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return Money |
||
61 | */ |
||
62 | 3 | public function getAmount(): Money |
|
63 | { |
||
64 | 3 | return $this->amount; |
|
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return int |
||
69 | */ |
||
70 | 3 | public function getCurrency(): int |
|
71 | { |
||
72 | 3 | return $this->currency; |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @return string |
||
77 | */ |
||
78 | 3 | public function getLanguage(): string |
|
79 | { |
||
80 | 3 | return $this->language; |
|
81 | } |
||
82 | |||
83 | /** |
||
84 | * @return bool |
||
85 | */ |
||
86 | 3 | public function isEmbeddedWindow(): bool |
|
87 | { |
||
88 | 3 | return $this->embeddedWindow; |
|
89 | } |
||
90 | } |
||
91 |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.