TransactionService   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 26
loc 26
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createTransactionBuilder() 4 4 1
A create() 8 8 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\Services;
4
5
use WSW\SiftScience\Events\Transaction;
6
use WSW\SiftScience\Support\Traits\Transformers\Fractal;
7
use WSW\SiftScience\Transformers\Events\TransactionTransformer;
8
9
/**
10
 * Class TransactionService
11
 *
12
 * @package WSW\SiftScience\Services
13
 * @author Ronaldo Matos Rodrigues <[email protected]>
14
 */
15 View Code Duplication
class TransactionService extends BaseService
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...
16
{
17
    use Fractal;
18
19
    /**
20
     * @return Transaction
21
     */
22 1
    public function createTransactionBuilder()
23
    {
24 1
        return new Transaction();
25
    }
26
27
    /**
28
     * @param Transaction $event
29
     *
30
     * @return bool
31
     */
32 2
    public function create(Transaction $event)
33
    {
34 2
        $event->setApiKey($this->credentials->getApiKey());
35 2
        $body = $this->loadItem($event, new TransactionTransformer)->toJson();
36 2
        $this->post(static::ENDPOINT, $body);
37
38 1
        return true;
39
    }
40
}
41