Client::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\cdc;
6
7
/**
8
 * CDC client class.
9
 *
10
 * @package SimpleSAMLphp
11
 */
12
13
class Client
14
{
15
    /**
16
     * Our CDC domain.
17
     *
18
     * @var string
19
     */
20
    private string $domain;
21
22
    /**
23
     * The CDC server we send requests to.
24
     *
25
     * @var Server
26
     */
27
    private Server $server;
28
29
30
    /**
31
     * Initialize a CDC client.
32
     *
33
     * @param string $domain  The domain we should query the server for.
34
     */
35
    public function __construct(string $domain)
36
    {
37
        $this->domain = $domain;
38
        $this->server = new Server($domain);
39
    }
40
41
42
    /**
43
     * Receive a CDC response.
44
     *
45
     * @return array|null  The response, or NULL if no response is received.
46
     */
47
    public function getResponse(): ?array
48
    {
49
        return $this->server->getResponse();
50
    }
51
52
53
    /**
54
     * Send a request.
55
     *
56
     * @param string $returnTo  The URL we should return to afterwards.
57
     * @param string $op  The operation we are performing.
58
     * @param array $params  Additional parameters.
59
     */
60
    public function sendRequest(string $returnTo, string $op, array $params = []): void
61
    {
62
        $params['op'] = $op;
63
        $params['return'] = $returnTo;
64
        $this->server->sendRequest($params);
65
    }
66
}
67