Locator::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 9
loc 9
ccs 4
cts 4
cp 1
crap 2
rs 9.9666
c 0
b 0
f 0
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