Manager::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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