SubscriptionService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 5
dl 0
loc 36
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createChargeBuilder() 0 4 1
A cancel() 0 9 1
A charge() 0 9 1
1
<?php
2
namespace PHPSC\PagSeguro\Purchases\Subscriptions;
3
4
use DateTime;
5
use PHPSC\PagSeguro\Purchases\SubscriptionService as SubscriptionServiceInterface;
6
use PHPSC\PagSeguro\Service;
7
8
/**
9
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
10
 */
11
class SubscriptionService extends Service implements SubscriptionServiceInterface
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 1
    public function createChargeBuilder($code)
17
    {
18 1
        return new ChargeBuilder($code);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function cancel($code)
25
    {
26 1
        $response = $this->get(static::CANCEL_ENDPOINT . '/' . $code);
27
28 1
        return new CancellationResponse(
29 1
            (string) $response->status,
30 1
            new DateTime((string) $response->date)
31
        );
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 1
    public function charge(Charge $charge)
38
    {
39 1
        $response = $this->post(static::CHARGE_ENDPOINT, $charge->xmlSerialize());
40
41 1
        return new ChargeResponse(
42 1
            (string) $response->transactionCode,
43 1
            new DateTime((string) $response->date)
44
        );
45
    }
46
}
47