Client::getResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
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
     * The CDC server we send requests to.
17
     *
18
     * @var \SimpleSAML\Module\cdc\Server
19
     */
20
    private Server $server;
21
22
23
    /**
24
     * Initialize a CDC client.
25
     *
26
     * @param string $domain  The domain we should query the server for.
27
     */
28
    public function __construct(
29
        protected string $domain,
30
    ) {
31
        $this->server = new Server($domain);
32
    }
33
34
35
    /**
36
     * Receive a CDC response.
37
     *
38
     * @return array<mixed>|null  The response, or NULL if no response is received.
39
     */
40
    public function getResponse(): ?array
41
    {
42
        return $this->server->getResponse();
43
    }
44
45
46
    /**
47
     * Send a request.
48
     *
49
     * @param string $returnTo  The URL we should return to afterwards.
50
     * @param string $op  The operation we are performing.
51
     * @param array<mixed> $params  Additional parameters.
52
     */
53
    public function sendRequest(string $returnTo, string $op, array $params = []): void
54
    {
55
        $params['op'] = $op;
56
        $params['return'] = $returnTo;
57
        $this->server->sendRequest($params);
58
    }
59
}
60