Client::order()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the LetsEncrypt ACME client.
7
 *
8
 * @author    Ivanov Aleksandr <[email protected]>
9
 * @copyright 2019-2020
10
 * @license   https://github.com/misantron/letsencrypt-client/blob/master/LICENSE MIT License
11
 */
12
13
namespace LetsEncrypt;
14
15
use LetsEncrypt\Helper\KeyGenerator;
16
use LetsEncrypt\Http\Connector;
17
use LetsEncrypt\Logger\Logger;
18
use LetsEncrypt\Service\AccountService;
19
use LetsEncrypt\Service\AuthorizationService;
20
use LetsEncrypt\Service\OrderService;
21
22
class Client
23
{
24
    /**
25
     * @var Connector
26
     */
27
    private $connector;
28
29
    /**
30
     * @var AccountService
31
     */
32
    private $accountService;
33
34
    /**
35
     * @var OrderService
36
     */
37
    private $orderService;
38
39
    public function __construct(
40
        string $accountKeysPath,
41
        string $certificatesPath,
42
        bool $staging = true,
43
        Logger $logger = null
44
    ) {
45
        $this->connector = new Connector($staging, $logger);
46
47
        $authorizationService = new AuthorizationService();
48
        $authorizationService->setConnector($this->connector);
49
50
        $keyGenerator = new KeyGenerator();
51
52
        $this->accountService = new AccountService($accountKeysPath);
53
        $this->accountService->setKeyGenerator($keyGenerator);
54
55
        $this->orderService = new OrderService($authorizationService, $certificatesPath);
56
        $this->orderService->setKeyGenerator($keyGenerator);
57
    }
58
59
    public function account(): AccountService
60
    {
61
        return $this->accountService->setConnector($this->connector);
62
    }
63
64
    public function order(): OrderService
65
    {
66
        return $this->orderService->setConnector($this->connector);
67
    }
68
}
69