Locator   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 43
loc 43
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 9 9 2
A getByCode() 4 4 1
A getByNotification() 4 4 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
namespace PHPSC\PagSeguro\Purchases\Subscriptions;
3
4
use PHPSC\PagSeguro\Client\Client;
5
use PHPSC\PagSeguro\Credentials;
6
use PHPSC\PagSeguro\Purchases\NotificationService;
7
use PHPSC\PagSeguro\Purchases\SearchService;
8
use PHPSC\PagSeguro\Service;
9
10
/**
11
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
12
 */
13 View Code Duplication
class Locator extends Service implements SearchService, NotificationService
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...
14
{
15
    /**
16
     * @var string
17
     */
18
    const ENDPOINT = '/v2/pre-approvals';
19
20
    /**
21
     * @var Decoder
22
     */
23
    private $decoder;
24
25
    /**
26
     * @param Credentials $credentials
27
     * @param Client $client
28
     * @param Decoder $decoder
29
     */
30 3
    public function __construct(
31
        Credentials $credentials,
32
        Client $client = null,
33
        Decoder $decoder = null
34
    ) {
35 3
        parent::__construct($credentials, $client);
36
37 3
        $this->decoder = $decoder ?: new Decoder();
38 3
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 1
    public function getByCode($code)
44
    {
45 1
        return $this->decoder->decode($this->get(static::ENDPOINT . '/' . $code));
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function getByNotification($code)
52
    {
53 1
        return $this->decoder->decode($this->get(static::ENDPOINT . '/notifications/' . $code));
54
    }
55
}
56