blob: bdd971a111237eb0684db531f1de2a062f539ff0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
<?php
namespace Matrix\Responses;
use Matrix\Data\Contact;
use Matrix\Response;
class WellKnownMatrixSupportGetResponse extends Response
{
/**
* @param Contact[] $contacts
*/
public function __construct(
private ?array $contacts = null,
private ?string $supportPage = null,
)
{
if (is_null($contacts) && is_null($supportPage)) {
throw new \InvalidArgumentException("at least one of contacts or supportPage is required");
}
if (! is_null($contacts) && is_null($supportPage) && empty($contacts)) {
throw new \InvalidArgumentException("if only contacts is set, it must contain at least one item");
}
}
public function getBody(): array
{
return array_filter([
"contacts" => $this->contacts,
"support_page" => $this->supportPage,
], fn ($value) => ! is_null($value));
}
}
|