1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace WSW\SiftScience\Transformers\Events; |
4
|
|
|
|
5
|
|
|
use WSW\SiftScience\Events\Transaction; |
6
|
|
|
use WSW\SiftScience\Support\Traits\Transformers\ObjectValues; |
7
|
|
|
use WSW\SiftScience\Support\Traits\Transformers\Relationships; |
8
|
|
|
use WSW\SiftScience\Transformers\AbstractTransformer; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class TransactionTransformer |
12
|
|
|
* |
13
|
|
|
* @package WSW\SiftScience\Transformers\Events |
14
|
|
|
* @author Ronaldo Matos Rodrigues <[email protected]> |
15
|
|
|
*/ |
16
|
|
View Code Duplication |
class TransactionTransformer extends AbstractTransformer |
|
|
|
|
17
|
|
|
{ |
18
|
|
|
use Relationships; |
19
|
|
|
use ObjectValues; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param Transaction $event |
23
|
|
|
* |
24
|
|
|
* @return array |
25
|
|
|
*/ |
26
|
2 |
|
public function transform(Transaction $event) |
27
|
|
|
{ |
28
|
|
|
$data = [ |
29
|
2 |
|
'$type' => $event->getType(), |
30
|
2 |
|
'$api_key' => $event->getApiKey(), |
31
|
2 |
|
'$user_id' => $event->getUserId(), |
32
|
2 |
|
'$user_email' => $this->email($event->getUserEmail()), |
33
|
2 |
|
'$ip' => $event->getIp(), |
34
|
2 |
|
'$time' => $this->dateTime($event->getTime()), |
35
|
2 |
|
'$transaction_type' => $event->getTransactionType(), |
36
|
2 |
|
'$transaction_status' => $event->getTransactionStatus(), |
37
|
2 |
|
'$amount' => $this->amount($event->getAmount()), |
38
|
2 |
|
'$currency_code' => $this->currency($event->getAmount()), |
39
|
2 |
|
'$order_id' => $event->getOrderId(), |
40
|
2 |
|
'$transaction_id' => $event->getId(), |
41
|
2 |
|
'$payment_method' => $this->paymentMethod($event->getPaymentMethod()), |
42
|
2 |
|
'$billing_address' => $this->address($event->getBillingAddress()), |
43
|
2 |
|
'$shipping_address' => $this->address($event->getShippingAddress()), |
44
|
2 |
|
'$session_id' => $event->getSessionId(), |
45
|
2 |
|
'$seller_user_id' => $event->getSellerUserId(), |
46
|
2 |
|
'$transfer_recipient_user_id' => $event->getTransferRecipientUserId() |
47
|
|
|
]; |
48
|
|
|
|
49
|
2 |
|
return $this->result($event, $data); |
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.