Manager   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 69
ccs 15
cts 15
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A setTimeout() 0 6 1
A setConnectTimeout() 0 6 1
A setHostname() 0 6 1
A report() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of Pachico\MaxMind\MinFraudChargeback. (https://github.com/pachico/maxmind-minfraud-chargeback)
5
 *
6
 * @link https://github.com/pachico/maxmind-minfraud-chargeback for the canonical source repository
7
 * @copyright Copyright (c) 2016-2017 Mariano F.co Benítez Mulet. (https://github.com/pachico/)
8
 * @license https://raw.githubusercontent.com/pachico/maxmind-minfraud-chargeback/master/LICENSE.md MIT
9
 */
10
11
namespace Pachico\MaxMind\MinFraudChargeback;
12
13
use Pachico\MaxMind\MinFraudChargeback\Auth\Credential;
14
use Pachico\MaxMind\MinFraudChargeback\Http\ClientInterface;
15
use Pachico\MaxMind\MinFraudChargeback\Http\CurlClient;
16
17
/**
18
 * External layer for reporting chargebacks
19
 */
20
class Manager
21
{
22
    /**
23
     * @var Credential
24
     */
25
    protected $credential;
26
    /**
27
     * @var ClientInterface
28
     */
29
    protected $httpClient;
30
31
    /**
32
     * @param Credential $credential
33
     * @param ClientInterface $httpClient
34
     */
35 4
    public function __construct(Credential $credential, ClientInterface $httpClient = null)
36
    {
37 4
        $this->credential = $credential;
38 4
        $this->httpClient = $httpClient ? : new CurlClient($credential);
39 4
    }
40
41
    /**
42
     * @param string $seconds
43
     *
44
     * @return Manager
45
     */
46 1
    public function setTimeout($seconds)
47
    {
48 1
        $this->httpClient->setTimeout($seconds);
49
50 1
        return $this;
51
    }
52
53
    /**
54
     * @param int $seconds
55
     *
56
     * @return Manager
57
     */
58 1
    public function setConnectTimeout($seconds)
59
    {
60 1
        $this->httpClient->setConnectTimeout($seconds);
61
62 1
        return $this;
63
    }
64
65
    /**
66
     * @param string $hostname
67
     *
68
     * @return Manager
69
     */
70 1
    public function setHostname($hostname)
71
    {
72 1
        $this->httpClient->setHostname($hostname);
73
74 1
        return $this;
75
    }
76
77
    /**
78
     * @param Chargeback $chargeback
79
     *
80
     * @return true
81
     *
82
     * @throws Exception\ExceptionAbstract
83
     */
84 1
    public function report(Chargeback $chargeback)
85
    {
86 1
        return $this->httpClient->report($chargeback);
87
    }
88
}
89