TransactionTransformer   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 4
dl 36
loc 36
ccs 20
cts 20
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B transform() 25 25 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

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.

Loading history...
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