Issues (6)

src/PagaMasTarde/PmtApiClient.php (1 issue)

1
<?php
2
3
namespace PagaMasTarde;
4
5
use PagaMasTarde\Service\ChargeService;
6
7
/**
8
 * This is a direct access to al the API services. You can access by the endpoint or you can instance
9
 * directly the class:
10
 *
11
 * $pmtApiClient->charge()->getCharges();
12
 *
13
 * or
14
 *
15
 * $charge = new Charge($privateKey, $baseUri);
16
 * $charge->getCharges();
17
 *
18
 * Class PmtApiClient
19
 * @package PagaMasTarde
20
 */
21
class PmtApiClient
22
{
23
    /**
24
     * @var ChargeService
25
     */
26
    protected $charge;
27
28
    /**
29
     * Private key for API calls
30
     *
31
     * @var string
32
     */
33
    protected $privateKey;
34
35
    /**
36
     * @var string
37
     */
38
    protected $baseUri;
39
40
    /**
41
     * PmtApiClient constructor.
42
     *
43
     * @param string $privateKey
44
     * @param null   $baseUri
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $baseUri is correct as it would always require null to be passed?
Loading history...
45
     */
46
    public function __construct($privateKey, $baseUri = null)
47
    {
48
        $this->privateKey = trim($privateKey);
49
        $this->baseUri = $baseUri;
50
    }
51
52
    /**
53
     * @return ChargeService
54
     */
55
    public function charge()
56
    {
57
        if (! $this->charge instanceof ChargeService) {
58
            $this->charge = new ChargeService($this->privateKey, $this->baseUri);
59
        }
60
61
        return $this->charge;
62
    }
63
}
64